FLTK logo

[master] 132e7d4 - Fix MSVC warnings (#966)

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] 132e7d4 - Fix MSVC warnings (#966) "Matthias Melcher" 12:47 May 02  
 
commit 132e7d4e32836bba9d840c177baac02b7e441a40
Author:     Matthias Melcher <github@matthiasm.com>
AuthorDate: Thu May 2 21:46:12 2024 +0200
Commit:     Matthias Melcher <github@matthiasm.com>
CommitDate: Thu May 2 21:46:12 2024 +0200

    Fix MSVC warnings (#966)

 fluid/autodoc.cxx | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git fluid/autodoc.cxx fluid/autodoc.cxx
index b34dcc9..b12a848 100644
--- fluid/autodoc.cxx
+++ fluid/autodoc.cxx
@@ -120,7 +120,7 @@ void blend_alpha_left(const Fl_RGB_Image *img, int dx) {
   if (dx > 0) {
     int max_x = dx, max_y = img->h();
     int ld = img->ld(); if (ld == 0) ld = img->w() * img->d();
-    float a = 255/max_x;
+    float a = 255.0f/static_cast<float>(max_x);
     for (int i = 0; i < max_x; i++) {
       uchar *rgba = (uchar*)img->data()[0] + i * img->d();
       uchar alpha = static_cast<uchar>(i * a);
@@ -145,7 +145,7 @@ void blend_alpha_top(const Fl_RGB_Image *img, int dy) {
   if (dy > 0) {
     int max_x = img->w(), max_y = dy;
     int ld = img->ld(); if (ld == 0) ld = img->w() * img->d();
-    float a = 255/max_y;
+    float a = 255.0f/static_cast<float>(max_y);
     for (int i = 0; i < max_y; i++) {
       uchar *rgba = (uchar*)img->data()[0] + i * ld;
       uchar alpha = static_cast<uchar>(i * a);
@@ -170,7 +170,7 @@ void blend_alpha_right(const Fl_RGB_Image *img, int dx) {
   if (dx > 0) {
     int max_x = dx, max_y = img->h();
     int ld = img->ld(); if (ld == 0) ld = img->w() * img->d();
-    float a = 255/max_x;
+    float a = 255.0f/static_cast<float>(max_x);
     for (int i = 0; i < max_x; i++) {
       uchar *rgba = (uchar*)img->data()[0] + (img->w()-i-1) * img->d();
       uchar alpha = static_cast<uchar>(i * a);
@@ -195,7 +195,7 @@ void blend_alpha_bottom(const Fl_RGB_Image *img, int dy) {
   if (dy > 0) {
     int max_x = img->w(), max_y = dy;
     int ld = img->ld(); if (ld == 0) ld = img->w() * img->d();
-    float a = 255/max_y;
+    float a = 255.0f/static_cast<float>(max_y);
     for (int i = 0; i < max_y; i++) {
       uchar *rgba = (uchar*)img->data()[0] + (img->h()-i-1) * ld;
       uchar alpha = static_cast<uchar>(i * a);
@@ -305,7 +305,10 @@ int fl_snapshot(const char *filename, Fl_Widget **w,
   // If scale is set, scale the image
   if (scale != 1.0) {
     Fl_Image::scaling_algorithm(FL_RGB_SCALING_BILINEAR);
-    Fl_RGB_Image *scaled_img = (Fl_RGB_Image*)img->copy(img->w()*scale, img->h()*scale);
+    int scaled_img_w = static_cast<int>(img->w()*scale);
+    int scaled_img_h = static_cast<int>(img->h()*scale);
+    Fl_RGB_Image *scaled_img =
+      static_cast<Fl_RGB_Image*>(img->copy(scaled_img_w, scaled_img_h));
     delete img;
     img = scaled_img;
   }
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'.