Главная страница
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.019 c
4-28333
serd_hhc
2002-10-26 05:36
2002.12.09
Как сделать следущее....


4-28342
GOD
2002-10-28 02:39
2002.12.09
Помогите!


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


14-28246
vopros
2002-11-18 11:22
2002.12.09
Порадуйте меня чем нибудь.


3-27908
Гарик
2002-11-21 15:56
2002.12.09
Tdbgrid