mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 03:15:21 +08:00
A better solution to the crash when printing the mandelbrot demo under WIN32.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8294 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -174,17 +174,18 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
|||||||
int linesize = (pixelsize*w+3)&~3;
|
int linesize = (pixelsize*w+3)&~3;
|
||||||
|
|
||||||
static U32* buffer;
|
static U32* buffer;
|
||||||
|
static long buffer_size;
|
||||||
int blocking = h;
|
int blocking = h;
|
||||||
{int size = linesize*h;
|
{int size = linesize*h;
|
||||||
if (size > MAXBUFFER) {
|
// when printing, don't limit buffer size not to get a crash in StretchDIBits
|
||||||
|
if (size > MAXBUFFER && Fl_Surface_Device::surface()->class_name() != Fl_Printer::class_id) {
|
||||||
size = MAXBUFFER;
|
size = MAXBUFFER;
|
||||||
blocking = MAXBUFFER/linesize;
|
blocking = MAXBUFFER/linesize;
|
||||||
}
|
}
|
||||||
static long buffer_size;
|
|
||||||
if (size > buffer_size) {
|
if (size > buffer_size) {
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
buffer_size = size;
|
buffer_size = size;
|
||||||
buffer = new U32[(int)(1.02* (size+3)/4)]; // some extra memory needed when printing
|
buffer = new U32[(size+3)/4];
|
||||||
}}
|
}}
|
||||||
bmi.bmiHeader.biHeight = blocking;
|
bmi.bmiHeader.biHeight = blocking;
|
||||||
static U32* line_buffer;
|
static U32* line_buffer;
|
||||||
@@ -267,6 +268,9 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
|||||||
DIB_RGB_COLORS
|
DIB_RGB_COLORS
|
||||||
#endif
|
#endif
|
||||||
, SRCCOPY );
|
, SRCCOPY );
|
||||||
|
delete[] buffer;
|
||||||
|
buffer = NULL;
|
||||||
|
buffer_size = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SetDIBitsToDevice(fl_gc, x, y+j-k, w, k, 0, 0, 0, k,
|
SetDIBitsToDevice(fl_gc, x, y+j-k, w, k, 0, 0, 0, k,
|
||||||
|
|||||||
Reference in New Issue
Block a user