CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving bitmaps to disk



The Graphics::TBitmap -> SaveToFile() gives me an 'access violation'. The
Call Stack says this occurs to in SaveToStream which is apparently called
by SaveToFile.

I would greatly appreciate it if anyone can find a basic flaw in the code
below or show me an example where they've taken something off a Canvas
and saved it to file. I'm working with Builder Pro version 1 should that
matter.

I don't have the precise code but it's pretty simple and something like
this.
I've compiled this successfully so please ignore any typos below.

// I've already drawn on TImage MyMap and I can see it on the screen so I
know // it's good.

Graphics::TBitmap * TempMap = new Graphics::TBitmap() ;

TRect destination_rectangle, source_rectangle ;
// Define source and destination rectangles. Not typed in but I've
checked // these by stepping
// and inspecting. They have correct valus: 0,0, 1700, 1500.

// This steps correctly without error reported.
TempMap -> Canvas -> CopyRect(destination_rectangle, MyMap -> Canvas, 
			source_rectangle)

TempMap -> SaveToFile("MyMap.bmp") ;
// This is the line where the access violation occurs.
// A file called "MyMap.bmp" is created with nothing in it.


delete TempMap ;


Thom Burnett


W Komornicki's Home Page | Main Index | Thread Index