Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.12.09;
Скачать: [xml.tar.bz2];

Вниз

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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.009 c
6-28173
Andr e
2002-10-15 10:13
2002.12.09
ping HUB or Switch


4-28374
gogol
2002-10-24 08:17
2002.12.09
Help


14-28249
sad
2002-11-18 11:48
2002.12.09
Личная страничка на narod.ru


7-28313
Th
2002-10-08 21:09
2002.12.09
Как использовать средства DDK в Delphi


3-27828
Виталий Викторович Яничкин
2002-11-14 21:01
2002.12.09
отлавливание событий InterBase





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский