Handle para TMemoryStream
Eu tenho a seguinte variável declarada -> ImageStream : TMemoryStream;
e tenho a seguinte atribuição -> Bitmap.SaveToStream(ImageStream);
Como eu faço para utilizar o conteúdo da variável [b:9574d7b1d3]ImageStream [/b:9574d7b1d3]no procedimento abaixo:
procedure ReadNative(Handle: Cardinal; var Cancel: Boolean);
var
DibInfo: ^TBITMAPINFO;
ColorTableSize: Integer;
lpBits: PChar;
DC: HDC;
BitmapHandle: HBitmap;
{$IFNDEF DONTUSEVCL}BitmapObj: TBitmap;{$ENDIF}
begin
DibInfo := GlobalLock(Handle);
ColorTableSize := (DibNumColors(DibInfo) * SizeOf(RGBQUAD));
lpBits := PChar(DibInfo);
Inc(lpBits, DibInfo.bmiHeader.biSize);
Inc(lpBits, ColorTableSize);
DC := GetDC(Owner.VirtualWindow);
BitmapHandle := CreateDIBitmap(DC, DibInfo.bmiHeader, CBM_INIT,
lpBits, DibInfo^, DIB_RGB_COLORS);
ReleaseDC(Owner.VirtualWindow, DC);
if Assigned(Owner.OnTwainAcquire) then
{$IFDEF DONTUSEVCL}
Owner.OnTwainAcquire(Owner, Index, BitmapHandle, Cancel); {$ELSE}
begin
BitmapObj := TBitmap.Create;
BitmapObj.Handle := BitmapHandle;
Owner.OnTwainAcquire(Owner, Index, BitmapObj, Cancel);
BitmapObj.Free;
end; {$ENDIF}
GlobalUnlock(Handle);
GlobalFree(Handle);
end;
e tenho a seguinte atribuição -> Bitmap.SaveToStream(ImageStream);
Como eu faço para utilizar o conteúdo da variável [b:9574d7b1d3]ImageStream [/b:9574d7b1d3]no procedimento abaixo:
procedure ReadNative(Handle: Cardinal; var Cancel: Boolean);
var
DibInfo: ^TBITMAPINFO;
ColorTableSize: Integer;
lpBits: PChar;
DC: HDC;
BitmapHandle: HBitmap;
{$IFNDEF DONTUSEVCL}BitmapObj: TBitmap;{$ENDIF}
begin
DibInfo := GlobalLock(Handle);
ColorTableSize := (DibNumColors(DibInfo) * SizeOf(RGBQUAD));
lpBits := PChar(DibInfo);
Inc(lpBits, DibInfo.bmiHeader.biSize);
Inc(lpBits, ColorTableSize);
DC := GetDC(Owner.VirtualWindow);
BitmapHandle := CreateDIBitmap(DC, DibInfo.bmiHeader, CBM_INIT,
lpBits, DibInfo^, DIB_RGB_COLORS);
ReleaseDC(Owner.VirtualWindow, DC);
if Assigned(Owner.OnTwainAcquire) then
{$IFDEF DONTUSEVCL}
Owner.OnTwainAcquire(Owner, Index, BitmapHandle, Cancel); {$ELSE}
begin
BitmapObj := TBitmap.Create;
BitmapObj.Handle := BitmapHandle;
Owner.OnTwainAcquire(Owner, Index, BitmapObj, Cancel);
BitmapObj.Free;
end; {$ENDIF}
GlobalUnlock(Handle);
GlobalFree(Handle);
end;
Andregcoimbra
Curtidas 0