Olevariant to bitmap

Please discuss general Delphi programming topics here.

Olevariant to bitmap

Postby Arlon » July 9th, 2003, 11:54 am

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
Arlon
Member
Member
 
Posts: 1
Joined: July 9th, 2003, 11:46 am

Postby Kambiz » July 12th, 2003, 11:20 am

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
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests