Add implementation for fl_read_image() on OSX (STR #161)
Update changelog and announcement. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3096 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
f6a1e8ca40
commit
c704b6ad8e
@ -32,6 +32,8 @@ exceptions that allow for static linking.
|
||||
|
||||
Changes since FLTK 1.1.3 include:
|
||||
|
||||
- The fl_read_image() function was not implemented on
|
||||
OSX (STR #161)
|
||||
- VC++ 7.1 didn't like how the copy operators were
|
||||
disabled for the Fl_Widget class; now include inline
|
||||
code which will never be used but makes VC++ happy
|
||||
@ -265,6 +267,8 @@ exceptions that allow for static linking.
|
||||
|
||||
<UL>
|
||||
|
||||
<LI>The fl_read_image() function was not implemented on
|
||||
OSX (<A HREF="http://www.fltk.org/str.php?L161">STR #161</A>)
|
||||
<LI>VC++ 7.1 didn't like how the copy operators were
|
||||
disabled for the Fl_Widget class; now include inline
|
||||
code which will never be used but makes VC++ happy
|
||||
|
2
CHANGES
2
CHANGES
@ -1,5 +1,7 @@
|
||||
CHANGES IN FLTK 1.1.4
|
||||
|
||||
- The fl_read_image() function was not implemented on
|
||||
OSX (STR #161)
|
||||
- VC++ 7.1 didn't like how the copy operators were
|
||||
disabled for the Fl_Widget class; now include inline
|
||||
code which will never be used but makes VC++ happy
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: fl_read_image_mac.cxx,v 1.1.2.2 2003/01/30 21:44:03 easysw Exp $"
|
||||
// "$Id: fl_read_image_mac.cxx,v 1.1.2.3 2003/09/08 17:30:06 easysw Exp $"
|
||||
//
|
||||
// WIN32 image reading routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -34,10 +34,89 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
||||
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;
|
||||
Rect src, // Source rectangle
|
||||
dst; // Destination rectangle
|
||||
Fl_Offscreen osbuffer; // Temporary off-screen buffer for copy
|
||||
GrafPtr srcPort, // Source port
|
||||
dstPort; // Destination port
|
||||
RGBColor rgb; // RGB colors for copy mask...
|
||||
PixMapHandle pm; // Pixmap handle for off-screen buffer
|
||||
uchar *base, // Base address of off-screen buffer
|
||||
*psrc, // Pointer into off-screen buffer
|
||||
*pdst; // Pointer into pixel buffer
|
||||
int x, y; // Current X & Y in image
|
||||
int d; // Depth of image
|
||||
int rowBytes; // Number of bytes per row...
|
||||
|
||||
|
||||
// Get an off-screen buffer for copying the image...
|
||||
osbuffer = fl_create_offscreen(w,h);
|
||||
|
||||
if (!osbuffer) return 0;
|
||||
|
||||
// Set the source and destination rectangles...
|
||||
src.top = y;
|
||||
src.left = x;
|
||||
src.bottom = y + h;
|
||||
src.right = x + w;
|
||||
|
||||
dst.top = 0;
|
||||
dst.left = 0;
|
||||
dst.bottom = h;
|
||||
dst.right = w;
|
||||
|
||||
// Get the source port...
|
||||
GetPort(&srcPort);
|
||||
|
||||
// Set the RGB copy mask via the foreground/background colors...
|
||||
rgb.red = 0xffff;
|
||||
rgb.green = 0xffff;
|
||||
rgb.blue = 0xffff;
|
||||
RGBBackColor(&rgb);
|
||||
|
||||
rgb.red = 0x0000;
|
||||
rgb.green = 0x0000;
|
||||
rgb.blue = 0x0000;
|
||||
RGBForeColor(&rgb);
|
||||
|
||||
// Copy the screen image to the off-screen buffer...
|
||||
CopyBits(GetPortBitMapForCopyBits(srcPort),
|
||||
GetPortBitMapForCopyBits(osbuffer), &src, &dst, srcCopy, 0L);
|
||||
|
||||
// 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);
|
||||
|
||||
// Set the correct port for the off-screen buffer and lock the buffer
|
||||
SetGWorld(osbuffer, 0);
|
||||
|
||||
pm = GetGWorldPixMap(osbuffer);
|
||||
LockPixels(pm);
|
||||
|
||||
base = (uchar *)GetPixBaseAddr(pm);
|
||||
rowBytes = (*pm)->rowBytes & 0x3fff;
|
||||
|
||||
// Copy the image from the off-screen buffer to the memory buffer.
|
||||
for (y = 0, pdst = p; y < h; y ++)
|
||||
for (x = 0, psrc = base + y * rowBytes + 1; x < w; x ++, psrc += 4, pdst += d) {
|
||||
pdst[0] = psrc[0];
|
||||
pdst[1] = psrc[1];
|
||||
pdst[2] = psrc[2];
|
||||
}
|
||||
}
|
||||
|
||||
// Unlock and delete the off-screen buffer, then return...
|
||||
UnlockPixels(pm);
|
||||
fl_delete_offscreen(osbuffer);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: fl_read_image_mac.cxx,v 1.1.2.2 2003/01/30 21:44:03 easysw Exp $".
|
||||
// End of "$Id: fl_read_image_mac.cxx,v 1.1.2.3 2003/09/08 17:30:06 easysw Exp $".
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user