FLTK logo

[branch-1.4] bced31e - Backport c28237d

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

[branch-1.4] bced31e - Backport c28237d "Matthias Melcher" Jul 16, 2025  
 
commit bced31e972ee3bbb5a234aa771bc9acadaf94a2a
Author:     Matthias Melcher <github@matthiasm.com>
AuthorDate: Wed Jul 16 11:53:50 2025 +0200
Commit:     Matthias Melcher <github@matthiasm.com>
CommitDate: Wed Jul 16 11:53:50 2025 +0200

    Backport c28237d
    
    Set default DPI to 300 in fl_write_png
    
    Previously, the DPI value was completely random, resulting
    in some interesting scaling when reading the png in other apps.

 src/fl_write_png.cxx | 4 ++++
 1 file changed, 4 insertions(+)

diff --git src/fl_write_png.cxx src/fl_write_png.cxx
index 0f98047..ffd7b10 100644
--- src/fl_write_png.cxx
+++ src/fl_write_png.cxx
@@ -151,6 +151,10 @@ int fl_write_png(const char *filename, const char *pixels, int w, int h, int d,
                PNG_FILTER_TYPE_DEFAULT);
   png_set_sRGB(pptr, iptr, PNG_sRGB_INTENT_PERCEPTUAL);
 
+  double dpi = 300.0;
+  int dots_per_meter = (int)(dpi / (2.54 / 100.0));
+  png_set_pHYs(pptr, iptr, dots_per_meter, dots_per_meter, PNG_RESOLUTION_METER);
+
   png_write_info(pptr, iptr);
 
   for (int i = 0; i < h; i++, ptr += ld) {
[ Direct Link to Message ]
 
     
[ Previous Message ] [ Next Message ]
 
 

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