summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-03-19 17:43:18 +0000
committerManolo Gouy <Manolo>2018-03-19 17:43:18 +0000
commit916b44e361f275555c5f22b9d91c973ccc089037 (patch)
treea36b734804a82d3e5d4bd900bc9031b8fe60d35a /src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
parentc4f7c09b7bacbfe19d1dcea5a28eeb30b1136a95 (diff)
New member function Fl_Image::scale(int width, int height) to set the FLTK size of an image.
Each image has now two sizes implemented as follows: - the pixel size is stored in private members pixel_w_ and pixel_h_ with public accessors pixel_w() and pixel_h() - the FLTK size is stored in private members w_ and h_ and read by w() and h() - when the image is constructed, the two sizes have the same value - the protected w(int) and h(int) member functions set both FLTK and pixel sizes. - the public scale(int, int) member function is essentially nothing but set the FLTK size and don't change the pixel size. - when the image is drawn, its FLTK size determines how big it is drawn, its pixel size determines how much data are available to draw it. FLTK 1.3.4 with FL_ABI_VERSION=10304 contained an equivalent member function but only for the Fl_Shared_Image class. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12776 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
index e9200f3c2..1bd4d8fbc 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
@@ -162,7 +162,7 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP,
if (!cgimg) {
CGColorSpaceRef lut = img->d()<=2 ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB();
int ld = img->ld();
- if (!ld) ld = img->w() * img->d();
+ if (!ld) ld = img->pixel_w() * img->d();
CGDataProviderRef src;
if ( has_feature(PRINTER) ) {
// When printing, the data at img->array are used when the printed page is completed,
@@ -172,16 +172,16 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP,
// is used to avoid repeating the copy operation if img is printed again.
// The CGImage data provider deletes the copy at the latest of these two events:
// deletion of img, and completion of the page where img was printed.
- size_t total = ld * img->h();
+ size_t total = ld * img->pixel_h();
uchar *copy = new uchar[total];
memcpy(copy, img->array, total);
src = CGDataProviderCreateWithData(NULL, copy, total, dataReleaseCB);
*Fl_Graphics_Driver::mask(img) = 1;
} else {
// the CGImage data provider must not release the image data.
- src = CGDataProviderCreateWithData(NULL, img->array, ld * img->h(), NULL);
+ src = CGDataProviderCreateWithData(NULL, img->array, ld * img->pixel_h(), NULL);
}
- cgimg = CGImageCreate(img->w(), img->h(), 8, img->d()*8, ld,
+ cgimg = CGImageCreate(img->pixel_w(), img->pixel_h(), 8, img->d()*8, ld,
lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
src, 0L, false, kCGRenderingIntentDefault);
*Fl_Graphics_Driver::id(img) = (fl_uintptr_t)cgimg;
@@ -193,22 +193,6 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP,
}
}
-int Fl_Quartz_Graphics_Driver::draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP) {
- int X, Y, W, H;
- fl_clip_box(XP,YP,WP,HP,X,Y,W,H); // X,Y,W,H will give the unclipped area of XP,YP,WP,HP
- if (W == 0 || H == 0) return 1;
- fl_push_no_clip(); // remove the FLTK clip that can't be rescaled
- CGContextSaveGState(gc_);
- CGContextClipToRect(gc_, CGRectMake(X, Y, W, H)); // this clip path will be rescaled & translated
- CGContextTranslateCTM(gc_, XP, YP);
- CGContextScaleCTM(gc_, float(WP)/img->w(), float(HP)/img->h());
- if (img->as_rgb_image()) draw(img->as_rgb_image(), 0, 0, img->w(), img->h(), 0, 0);
- else img->draw(0, 0, img->w(), img->h(), 0, 0);
- CGContextRestoreGState(gc_);
- fl_pop_clip(); // restore FLTK's clip
- return 1;
-}
-
void Fl_Quartz_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
if (Fl_Graphics_Driver::prepare(pxm, XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;
@@ -245,8 +229,8 @@ void Fl_Quartz_Graphics_Driver::uncache(Fl_RGB_Image*, fl_uintptr_t &id_, fl_uin
}
}
-fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const uchar *array) {
- return (fl_uintptr_t)create_bitmask(w, h, array);
+fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap *bm) {
+ return (fl_uintptr_t)create_bitmask(bm->pixel_w(), bm->pixel_h(), bm->array);
}
@@ -254,10 +238,10 @@ static void pmProviderRelease (void *ctxt, const void *data, size_t size) {
CFRelease(ctxt);
}
-fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) {
- Fl_Image_Surface *surf = new Fl_Image_Surface(w, h);
+fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img) {
+ Fl_Image_Surface *surf = new Fl_Image_Surface(img->pixel_w(), img->pixel_h());
Fl_Surface_Device::push_current(surf);
- fl_draw_pixmap(data, 0, 0, FL_BLACK);
+ fl_draw_pixmap(img->data(), 0, 0, FL_BLACK);
CGContextRef src = surf->get_offscreen_before_delete();
Fl_Surface_Device::pop_current();
delete surf;