FLTK logo

[master] 87ee126 - Allow use of Fl_Window::default_icon() with a scaled image.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 87ee126 - Allow use of Fl_Window::default_icon() with a scaled image. "ManoloFLTK" Sep 12, 2022  
 
commit 87ee126e1fabd5ae5b1bc6738ff46e0c2b149804
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Sep 12 11:07:03 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Sep 12 11:07:03 2022 +0200

    Allow use of Fl_Window::default_icon() with a scaled image.

 src/Fl_cocoa.mm  |  6 +++---
 src/Fl_win32.cxx | 22 +++++++++++-----------
 src/Fl_x.cxx     | 12 ++++++------
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git src/Fl_cocoa.mm src/Fl_cocoa.mm
index f021cb7..ddcb6d4 100644
--- src/Fl_cocoa.mm
+++ src/Fl_cocoa.mm
@@ -4627,15 +4627,15 @@ Fl_Cocoa_Window_Driver::~Fl_Cocoa_Window_Driver()
 static NSImage* rgb_to_nsimage(const Fl_RGB_Image *rgb) {
   if (!rgb) return nil;
   int ld = rgb->ld();
-  if (!ld) ld = rgb->w() * rgb->d();
+  if (!ld) ld = rgb->data_w() * rgb->d();
   NSImage *win_icon = nil;
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
   if (fl_mac_os_version >= 101000) {
-    NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:rgb->w() pixelsHigh:rgb->h()
+    NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:rgb->data_w() pixelsHigh:rgb->data_h()
                                                                     bitsPerSample:8 samplesPerPixel:rgb->d() hasAlpha:!(rgb->d() & 1) isPlanar:NO
                                                                    colorSpaceName:(rgb->d()<=2) ? NSDeviceWhiteColorSpace : NSDeviceRGBColorSpace
                                                                      bitmapFormat:NSAlphaNonpremultipliedBitmapFormat bytesPerRow:ld bitsPerPixel:rgb->d()*8]; // 10.4
-    memcpy([bitmap bitmapData], rgb->array, rgb->h() * ld);
+    memcpy([bitmap bitmapData], rgb->array, rgb->data_h() * ld);
     win_icon = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)];
     [win_icon addRepresentation:bitmap];
     [bitmap release];
diff --git src/Fl_win32.cxx src/Fl_win32.cxx
index da4dddc..47bf8d4 100644
--- src/Fl_win32.cxx
+++ src/Fl_win32.cxx
@@ -2307,17 +2307,17 @@ static HICON image_to_icon(const Fl_RGB_Image *image, bool is_icon, int hotx, in
   HICON icon;
 
   if (!is_icon) {
-    if ((hotx < 0) || (hotx >= image->w()))
+    if ((hotx < 0) || (hotx >= image->data_w()))
       return NULL;
-    if ((hoty < 0) || (hoty >= image->h()))
+    if ((hoty < 0) || (hoty >= image->data_h()))
       return NULL;
   }
 
   memset(&bi, 0, sizeof(BITMAPV5HEADER));
 
   bi.bV5Size        = sizeof(BITMAPV5HEADER);
-  bi.bV5Width       = image->w();
-  bi.bV5Height      = -image->h(); // Negative for top-down
+  bi.bV5Width       = image->data_w();
+  bi.bV5Height      = -image->data_h(); // Negative for top-down
   bi.bV5Planes      = 1;
   bi.bV5BitCount    = 32;
   bi.bV5Compression = BI_BITFIELDS;
@@ -2336,10 +2336,10 @@ static HICON image_to_icon(const Fl_RGB_Image *image, bool is_icon, int hotx, in
     return NULL;
 
   const uchar *i = (const uchar *)*image->data();
-  const int extra_data = image->ld() ? (image->ld() - image->w() * image->d()) : 0;
+  const int extra_data = image->ld() ? (image->ld() - image->data_w() * image->d()) : 0;
 
-  for (int y = 0; y < image->h(); y++) {
-    for (int x = 0; x < image->w(); x++) {
+  for (int y = 0; y < image->data_h(); y++) {
+    for (int x = 0; x < image->data_w(); x++) {
       switch (image->d()) {
         case 1:
           *bits = (0xff << 24) | (i[0] << 16) | (i[0] << 8) | i[0];
@@ -2361,7 +2361,7 @@ static HICON image_to_icon(const Fl_RGB_Image *image, bool is_icon, int hotx, in
   }
 
   // A mask bitmap is still needed even though it isn't used
-  mask = CreateBitmap(image->w(), image->h(), 1, 1, NULL);
+  mask = CreateBitmap(image->data_w(), image->data_h(), 1, 1, NULL);
   if (mask == NULL) {
     DeleteObject(bitmap);
     return NULL;
@@ -2397,11 +2397,11 @@ static const Fl_RGB_Image *find_best_icon(int ideal_width, const Fl_RGB_Image *i
     if (best == NULL)
       best = icons[i];
     else {
-      if (best->w() < ideal_width) {
-        if (icons[i]->w() > best->w())
+      if (best->data_w() < ideal_width) {
+        if (icons[i]->data_w() > best->data_w())
           best = icons[i];
       } else {
-        if ((icons[i]->w() >= ideal_width) && (icons[i]->w() < best->w()))
+        if ((icons[i]->data_w() >= ideal_width) && (icons[i]->data_w() < best->data_w()))
           best = icons[i];
       }
     }
diff --git src/Fl_x.cxx src/Fl_x.cxx
index 1a30e80..e5c970b 100644
--- src/Fl_x.cxx
+++ src/Fl_x.cxx
@@ -2696,7 +2696,7 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count,
 
   sz = 0;
   for (int i = 0;i < count;i++)
-    sz += 2 + icons[i]->w() * icons[i]->h();
+    sz += 2 + icons[i]->data_w() * icons[i]->data_h();
 
   // FIXME: Might want to sort the icons
 
@@ -2708,15 +2708,15 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count,
 
     image = icons[i];
 
-    data[0] = image->w();
-    data[1] = image->h();
+    data[0] = image->data_w();
+    data[1] = image->data_h();
     data += 2;
 
-    const int extra_data = image->ld() ? (image->ld()-image->w()*image->d()) : 0;
+    const int extra_data = image->ld() ? (image->ld() - image->data_w() * image->d()) : 0;
 
     const uchar *in = (const uchar*)*image->data();
-    for (int y = 0; y < image->h(); y++) {
-      for (int x = 0; x < image->w(); x++) {
+    for (int y = 0; y < image->data_h(); y++) {
+      for (int x = 0; x < image->data_w(); x++) {
         switch (image->d()) {
         case 1:
           *data = ( 0xff<<24) | (in[0]<<16) | (in[0]<<8) | in[0];
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.