Главная страница
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.018 c
14-28202
dinAlt
2002-11-16 12:33
2002.12.09
Открылся новый сайт!!!


6-28189
Алексей Ким
2002-10-11 12:16
2002.12.09
ламерский вопрос


14-28260
Карлсон
2002-11-16 15:16
2002.12.09
че-нить можно сделать?


7-28323
brestmarket
2002-09-28 13:08
2002.12.09
Киньте пожалуйста таблицу возвращаемых кодов клавиатуры.


14-28214
vok
2002-11-10 04:16
2002.12.09
Помогите с интегралами - крайне необходимо