Главная страница
    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
14-28257
Николай Быков
2002-11-18 17:23
2002.12.09
........


3-27860
NeyroSpace
2002-11-20 18:45
2002.12.09
Помогите ! Если форма создается динамически, то DBкомпоненты


14-28277
Ketmar
2002-11-15 18:20
2002.12.09
все. до-ве-ли! увольняюсь.


14-28237
stone
2002-11-18 09:36
2002.12.09
On-Line переводчик


14-28271
Masterlomaster
2002-11-19 07:03
2002.12.09
ПОМОГИТЕ ПЛИЗ,,,,,,,,,,,,,,, ЧЁРТ ЧЁ ДЕЛАТЬ!!!!!!!!!!!! ПОМОГИТЕ!





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский