mirror of https://github.com/fltk/fltk
Fixed Quartz image drawing and screen reading
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5614 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
32a8df787c
commit
fbd01308b9
4
CHANGES
4
CHANGES
|
@ -1,6 +1,8 @@
|
|||
CHANGES IN FLTK 1.1.8
|
||||
|
||||
- overlay drawing is now avoiding XOR mode (STR #1438)
|
||||
- Fixed Quartz image drawing bug (STR #1438)
|
||||
- Fixed Quartz fl_read_image
|
||||
- Overlay drawing is now avoiding XOR mode (STR #1438)
|
||||
- Fixed Scroll crash in Fluid Live Mode (STR #1524)
|
||||
- Fixed mousewheel event propagation (STR #1521)
|
||||
- Fixed drawing issues of a tile in a scroll (STR #1507)
|
||||
|
|
|
@ -175,7 +175,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
|||
cb(userdata, 0, i, W, tmpBuf+i*W*delta);
|
||||
}
|
||||
array = (void*)tmpBuf;
|
||||
linedelta = W;
|
||||
linedelta = W*delta;
|
||||
}
|
||||
// create an image context
|
||||
CGColorSpaceRef lut = 0;
|
||||
|
@ -183,8 +183,8 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
|||
lut = CGColorSpaceCreateDeviceGray();
|
||||
else
|
||||
lut = CGColorSpaceCreateDeviceRGB();
|
||||
CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, linedelta*H*delta, 0L);
|
||||
CGImageRef img = CGImageCreate( W, H, 8, 8*delta, linedelta*delta,
|
||||
CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, linedelta*H, 0L);
|
||||
CGImageRef img = CGImageCreate( W, H, 8, 8*delta, linedelta,
|
||||
lut, delta&1?kCGImageAlphaNone:kCGImageAlphaNoneSkipLast,
|
||||
src, 0L, false, kCGRenderingIntentDefault);
|
||||
// draw the image into the destination context
|
||||
|
|
|
@ -73,17 +73,17 @@ static void draw_current_rect() {
|
|||
if (bgE) { free(bgE); bgE = 0L; }
|
||||
if (bgW) { free(bgW); bgW = 0L; }
|
||||
if (pw>0 && ph>0) {
|
||||
bgN = fl_read_image(0L, px, py, pw, 1);
|
||||
bgE = fl_read_image(0L, px+pw-1, py, 1, ph);
|
||||
bgW = fl_read_image(0L, px, py, 1, ph);
|
||||
bgS = fl_read_image(0L, px, py+ph-1, pw, 1);
|
||||
bgE = fl_read_image(0L, px, py, 1, ph);
|
||||
bgW = fl_read_image(0L, px+pw-1, py, 1, ph);
|
||||
bgN = fl_read_image(0L, px, py, pw, 1);
|
||||
bgx = px; bgy = py;
|
||||
bgw = pw; bgh = ph;
|
||||
}
|
||||
fl_color(FL_BLACK);
|
||||
fl_color(FL_WHITE);
|
||||
fl_line_style(FL_SOLID);
|
||||
fl_rect(px, py, pw, ph);
|
||||
fl_color(FL_WHITE);
|
||||
fl_color(FL_BLACK);
|
||||
fl_line_style(FL_DOT);
|
||||
fl_rect(px, py, pw, ph);
|
||||
fl_line_style(FL_SOLID);
|
||||
|
@ -98,10 +98,10 @@ static void erase_current_rect() {
|
|||
draw_current_rect();
|
||||
# endif
|
||||
#else
|
||||
if (bgN) fl_draw_image(bgN, px, py, pw, 1);
|
||||
if (bgS) fl_draw_image(bgS, px, py+ph-1, pw, 1);
|
||||
if (bgE) fl_draw_image(bgE, px, py, 1, ph);
|
||||
if (bgW) fl_draw_image(bgW, px+pw-1, py, 1, ph);
|
||||
if (bgN) fl_draw_image(bgN, bgx, bgy, bgw, 1);
|
||||
if (bgS) fl_draw_image(bgS, bgx, bgy+bgh-1, bgw, 1);
|
||||
if (bgW) fl_draw_image(bgW, bgx, bgy, 1, bgh);
|
||||
if (bgE) fl_draw_image(bgE, bgx+bgw-1, bgy, 1, bgh);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
|||
int alpha) { // I - Alpha value for image (0 for none)
|
||||
Rect src, // Source rectangle
|
||||
dst; // Destination rectangle
|
||||
Fl_Offscreen osbuffer; // Temporary off-screen buffer for copy
|
||||
GWorldPtr osbuffer; // Temporary off-screen buffer for copy
|
||||
GrafPtr srcPort; // Source port
|
||||
RGBColor rgb; // RGB colors for copy mask...
|
||||
PixMapHandle pm; // Pixmap handle for off-screen buffer
|
||||
|
@ -54,12 +54,6 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
|||
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;
|
||||
|
@ -71,6 +65,14 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
|||
dst.bottom = h;
|
||||
dst.right = w;
|
||||
|
||||
// Get an off-screen buffer for copying the image...
|
||||
QDErr err = NewGWorld(&osbuffer, 0, &dst, 0L, 0L, 0);
|
||||
if (!osbuffer) return 0;
|
||||
if (err!=noErr) {
|
||||
DisposeGWorld(osbuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the source port...
|
||||
GetPort(&srcPort);
|
||||
|
||||
|
@ -121,10 +123,9 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
|||
pdst[2] = psrc[2];
|
||||
}
|
||||
#endif // __i386__
|
||||
|
||||
// Unlock and delete the off-screen buffer, then return...
|
||||
UnlockPixels(pm);
|
||||
fl_delete_offscreen(osbuffer);
|
||||
DisposeGWorld(osbuffer);
|
||||
|
||||
SetPort(srcPort);
|
||||
return p;
|
||||
|
|
|
@ -28,8 +28,11 @@
|
|||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/filename.H>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char b[1024];
|
||||
fl_filename_relative(b, 1024, "/Users/matt/proj/source");
|
||||
Fl_Window *window = new Fl_Window(300,180);
|
||||
Fl_Box *box = new Fl_Box(FL_UP_BOX,20,40,260,100,"Hello, World!");
|
||||
box->labelfont(FL_BOLD+FL_ITALIC);
|
||||
|
|
Loading…
Reference in New Issue