Board index » delphi » Store graphic

Store graphic

What is the quickest way to store graphic in bitmap format. I have this
function
Draw(x, y: Integer; g: TGraphic)
and in this function I want to store that graphic as bitmap. g could be
icon, jpeg image, gif image,...I need to store this into a stream or even
better into a buffer I allocated memory for. But it's important to convert
this image into bitmap, since this buffer will save into file and then I
have to know how to replay that image on other computer.
Or any othe suggestion how to handle "import" into my own file format and be
able to replay that.

Grega :)

 

Re:Store graphic


Grega,

Since you ask for quickest, but always need a bitmap, I would suggest that
converting the graphic to a bitmap just once, and saving the bitmap would
be the best approach.  Use a device independant bitmap format such as
pf24bit.  TBitmap has save/load from stream as I recall.

David

Quote
> What is the quickest way to store graphic in bitmap format. I have this
> function
> Draw(x, y: Integer; g: TGraphic)
> and in this function I want to store that graphic as bitmap. g could be
> icon, jpeg image, gif image,...I need to store this into a stream or
even
> better into a buffer I allocated memory for. But it's important to
convert
> this image into bitmap, since this buffer will save into file and then I
> have to know how to replay that image on other computer.
> Or any othe suggestion how to handle "import" into my own file format
and be
> able to replay that.

Re:Store graphic


Quote
Grega Loboda <grega.lob...@bigfoot.com> wrote in message

3b6792ef$1_2@dnews...

Quote
> What is the quickest way to store graphic in bitmap format. I have this
> function
> Draw(x, y: Integer; g: TGraphic)
> and in this function I want to store that graphic as bitmap. g could be
> icon, jpeg image, gif image,...I need to store this into a stream or even
> better into a buffer I allocated memory for. But it's important to convert
> this image into bitmap, since this buffer will save into file and then I
> have to know how to replay that image on other computer.
> Or any othe suggestion how to handle "import" into my own file format and
be
> able to replay that.

> Grega :)

Do you need something like this ? :

var
bitmap:tbitmap;
begin
bitmap:=tbitmap.create;
bitmap.pixelformat:=pf24bit;
bitmap.width:= g.width;
bitmap.height:= g.height;
bitmap.canvas.draw(0,0,g);
bitmap.savetofile('yourfilename here');
{if you want to save to a stream you can use a memorystream or a filestream
object in conjunction with the bitmap savetostream method}
bitmap.free;
end;

Re:Store graphic


Or,

var
  B :TBitmap;
begin
  B :=TBitmap.Create;
  B.Assign(aGraphic);
  B.SaveToFile(....);
.

--
http://www.techvette.com - Delphi and Corvette sources

Quote
"Francesco Savastano" <francescos...@tiscalinet.it> wrote in message

news:3b67e5fb_2@dnews...
Quote

> Grega Loboda <grega.lob...@bigfoot.com> wrote in message
> 3b6792ef$1_2@dnews...
> > What is the quickest way to store graphic in bitmap format. I have this
> > function
> > Draw(x, y: Integer; g: TGraphic)
> > and in this function I want to store that graphic as bitmap. g could be
> > icon, jpeg image, gif image,...I need to store this into a stream or
even
> > better into a buffer I allocated memory for. But it's important to
convert
> > this image into bitmap, since this buffer will save into file and then I
> > have to know how to replay that image on other computer.
> > Or any othe suggestion how to handle "import" into my own file format
and
> be
> > able to replay that.

> > Grega :)

> Do you need something like this ? :

> var
> bitmap:tbitmap;
> begin
> bitmap:=tbitmap.create;
> bitmap.pixelformat:=pf24bit;
> bitmap.width:= g.width;
> bitmap.height:= g.height;
> bitmap.canvas.draw(0,0,g);
> bitmap.savetofile('yourfilename here');
> {if you want to save to a stream you can use a memorystream or a
filestream
> object in conjunction with the bitmap savetostream method}
> bitmap.free;
> end;

Other Threads