Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I save a paintbox to a bitmap file?

453 views
Skip to first unread message

Carlos Ramírez

unread,
May 14, 2000, 3:00:00 AM5/14/00
to
I´m developing an image editor and I don´t know how to save the paintbox's
content into a bitmap or jpeg file.

Another problems:
When I minimize the form, the paintbox's image disapperars. How can I avoid
this?
When I draw a bitmap or jpeg image on the paintbox that is larger than the
paintbox's area, the scrollbars don´t appear although the paintbox is on a
scrollbox. How can I do a scrollable paintbox?
The above problems don't happen if I use a Timage component, but when I draw
on it, the image blinks. Why? How can I avoid that?

I`ll be very greateful if somebody can help me.

Carlos Ramírez E-mail: zen...@yupimail.com

Jeppe Andreasen

unread,
May 15, 2000, 3:00:00 AM5/15/00
to
Well .... if you Create a bitmap which has the same size as the paintbox,
we're on our way.

implementation
var My_Bitmap : Tbitmap;
...
procedure Form1Create ..... bla bla
begin
My_Bitmap := TBitmap.create;
My_Bitmap.width := PaintBox1.Width;
My_Bitmap.height := PaintBox1.Height;
end;

Now in your save procedure, copy the paintbox canvas to the bitmap :
Assuming you've already added a SavePictureDialog to your form do this

procedure ButtonSaveClick(sender .... bla bla...)
begin
bitblt(My_Bitmap.Canvas.Handle,0,0,PaintBox1.Width,PaintBox1.Height,
Form1.PaintBox1.Canvas.Handle,0,0,SrcCopy); ..... a fast way
to do it.
if SavePictureDialog1.execute then
My_Bitmap.SaveToFile(Savedialog1.Filename);
end;

there you go ..... if I haven't made mistakes that is ... he he

Hope it works ..... regards Jeppe Andreasen

0 new messages