Olevariant to bitmap

Posted:
July 9th, 2003, 11:54 am
by Arlon
I would like to make tbitmap from two olevariants. one of them contains the bitmap data, the other contains the size of the bitmap data. I would like to use that informations for a method which need a tbitmap variant.
I tried to make stream from the olevariants, but it doesn't work. please help me if you have same idea thank you

Posted:
July 12th, 2003, 11:20 am
by Kambiz
For storing a bitmap to an OleVariant you do not need to use two OleVariant variables.
The following procedures can be used for saving/loading a bitmap to/from an OleVariant.
- Code: Select all
procedure BitmapToOle(Bitmap: TBitmap; var Variant: OleVariant);
var
Stream: TStringStream;
begin
Stream := TStringStream.Create('');
try
Bitmap.SaveToStream(Stream);
Variant := Stream.DataString;
finally
Stream.Free;
end;
end;
procedure OleToBitmap(const Variant: OleVariant; Bitmap: TBitmap);
var
Stream: TStringStream;
begin
Stream := TStringStream.Create(Variant);
try
Bitmap.LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
Cheers,
Kambiz