Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.12.09;
Скачать: CL | DM;

Вниз

Swap to Fiend!!! Ау!!! Fiend? Отзовись, если что я в чате...   Найти похожие ветки 

 
F1 ©   (2002-11-28 11:09) [0]

Вот класс свопа,который позволяет вытаскивать и затваскивать битмапы кусочками. Только для разных массштабов тебе все равно придется либо маленькими кусочками, либо несколько свопов заводить...
Ну вот, смотри... Если что спрашивай...

TSwap = class
private
FFileName:String;
FStream:TStream;
FWidth:Integer;
FHeight:Integer;
FBytePerPixel:Integer;
public
constructor Create(FileName:String;Width,Height,BytePerPixel:Integer;StreamType:TStreamType=stAutoSelect);
destructor Destroy;
procedure GetBitmap(Bitmap:TBitmap;xBitmap,yBitmap,xSwap,ySwap,width,height:Integer);
procedure SetBitmap(Bitmap:TBitmap;xBitmap,yBitmap,xSwap,ySwap,width,height:Integer);
end;


---------------


constructor TSwap.Create;
var
MemoryStatus:TMEMORYSTATUS;
begin
FFileName:=FileName;
FWidth:=Width;
FHeight:=Height;
FBytePerPixel:=BytePerPixel;
if StreamType=stAutoSelect then
begin
GlobalMemoryStatus(MemoryStatus);
if MemoryStatus.dwAvailPhys>Width*Height*BytePerPixel then StreamType:=stMemory else StreamType:=stFile;
end;
if StreamType=stMemory then
begin
FStream:=TMemoryStream.Create;
if FileExists(FileName) then
(FStream as TMemoryStream).LoadFromFile(FileName);
end else
begin
if FileExists(FileName) then
FStream:=TFileStream.Create(FileName,fmOpenReadWrite)
else
FStream:=TFileStream.Create(FileName,fmCreate);
end;
if FStream.Size<FWidth*FHeight*FBytePerPixel then
FStream.Size:=FWidth*FHeight*FBytePerPixel;
end;

destructor TSwap.Destroy;
begin
if FStream is TMemoryStream then (FStream as TMemoryStream).SaveToFile(FFileName);
FStream.Free;
end;

procedure TSwap.GetBitmap;
Var
ix,iy,Pos:Integer;
P:PByteArray;
begin
for iy:=0 to Height-1 do
begin
FStream.Seek((ySwap+iy)*FWidth*FBytePerPixel+xSwap*FBytePerPixel,soFromBeginning);
P:=Bitmap.ScanLine[iy+yBitmap];
FStream.Read(P[xBitmap],Width*FBytePerPixel);
end;
end;

procedure TSwap.SetBitmap;
Var
ix,iy:Integer;
P:PByteArray;
begin
for iy:=0 to Height-1 do
begin
FStream.Seek((ySwap+iy)*FWidth*FBytePerPixel+xSwap*FBytePerPixel,soFromBeginning);
P:=Bitmap.ScanLine[iy+yBitmap];
FStream.Write(P[xBitmap],Width*FBytePerPixel);
end;
end;


 
F1 ©   (2002-11-28 11:39) [1]

Up


 
F1 ©   (2002-11-28 12:51) [2]

up



Страницы: 1 вся ветка

Текущий архив: 2002.12.09;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.017 c
7-28302
@Ujin
2002-10-06 15:41
2002.12.09
Как просто и быстро зарегистрировать расширение?


1-28076
][рюн
2002-11-27 20:53
2002.12.09
GetCurrentDir и его альтернатива...


14-28254
Ketmar
2002-11-16 20:35
2002.12.09
я сильный....


1-28107
D_V_I
2002-11-28 13:15
2002.12.09
MoveTo, Pen.Color и LineTo слишком медленные, надо быстрее


14-28278
deep.1
2002-11-18 00:49
2002.12.09
Люди кто юзал SAPI?