Add Matthias's WIN32 code to get an image from the current window; needs

testing!


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2272 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-05-31 12:47:49 +00:00
parent d5541b5cd6
commit 778d528093

View File

@ -1,5 +1,5 @@
//
// "$Id: fl_read_image_win32.cxx,v 1.1.2.1 2002/05/30 15:09:03 easysw Exp $"
// "$Id: fl_read_image_win32.cxx,v 1.1.2.2 2002/05/31 12:47:49 easysw Exp $"
//
// WIN32 image reading routines for the Fast Light Tool Kit (FLTK).
//
@ -29,15 +29,42 @@
uchar * // O - Pixel buffer or NULL if failed
fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
int x, // I - Left position
int y, // I - Top position
int X, // I - Left position
int Y, // I - Top position
int w, // I - Width of area to read
int h, // I - Height of area to read
int alpha) { // I - Alpha value for image (0 for none)
return 0;
int x, y; // Looping vars
int d; // Depth of image
uchar *ptr; // Pointer in image data
// Allocate the image data array as needed...
d = alpha ? 4 : 3;
if (!p) p = new uchar[w * h * d];
// Initialize the default colors/alpha in the whole image...
memset(p, alpha, w * h * d);
// Grab all of the pixels in the image, one at a time...
// MRS: there has to be a better way than this!
for (y = 0, ptr = p; y < h; y ++) {
for (x = 0; x < w; x ++, ptr += d) {
COLORREF c = GetPixel(fl_gc, X + x, Y + y);
ptr[0] = c;
c >>= 8;
ptr[1] = c;
c >>= 8;
ptr[2] = c;
}
}
return p;
}
//
// End of "$Id: fl_read_image_win32.cxx,v 1.1.2.1 2002/05/30 15:09:03 easysw Exp $".
// End of "$Id: fl_read_image_win32.cxx,v 1.1.2.2 2002/05/31 12:47:49 easysw Exp $".
//