[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master cf897be: Fix PNG dump from 32-bit display.
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master cf897be: Fix PNG dump from 32-bit display. |
Date: |
Wed, 28 Oct 2020 20:17:10 -0400 (EDT) |
branch: master
commit cf897be93ea03bdedf4dedcfbd271b4750db5756
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
Fix PNG dump from 32-bit display.
* src/ftcommon.c (FTDemo_Display_Print): The 32-bit mode needs
transformations to account for endianness and skip the top byte.
---
ChangeLog | 7 +++++++
src/ftcommon.c | 18 +++++++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 288c0fd..3cffe4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2020-10-28 Alexei Podtelezhnikov <apodtele@gmail.com>
+ Fix PNG dump from 32-bit display.
+
+ * src/ftcommon.c (FTDemo_Display_Print): The 32-bit mode needs
+ transformations to account for endianness and skip the top byte.
+
+2020-10-28 Alexei Podtelezhnikov <apodtele@gmail.com>
+
* graph/win32/grwin32.c (gr_win32_surface_init): Default to BITSPIXEL.
2020-10-27 Alexei Podtelezhnikov <apodtele@gmail.com>
diff --git a/src/ftcommon.c b/src/ftcommon.c
index a5c52d8..7973177 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -261,10 +261,8 @@
color_type = PNG_COLOR_TYPE_GRAY;
break;
case gr_pixel_mode_rgb24:
- color_type = PNG_COLOR_TYPE_RGB;
- break;
case gr_pixel_mode_rgb32:
- color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ color_type = PNG_COLOR_TYPE_RGB;
break;
default:
fprintf( stderr, "Unsupported color type\n" );
@@ -327,6 +325,20 @@
png_write_info( png_ptr, info_ptr );
+ if ( bit->mode == gr_pixel_mode_rgb32 )
+ {
+ const int x = 1;
+
+
+ if ( *(char*)&x ) /* little endian */
+ {
+ png_set_filler( png_ptr, 0, PNG_FILLER_AFTER );
+ png_set_bgr( png_ptr );
+ }
+ else
+ png_set_filler( png_ptr, 0, PNG_FILLER_BEFORE );
+ }
+
/* Write image rows */
row = bit->buffer;
if ( bit->pitch < 0 )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master cf897be: Fix PNG dump from 32-bit display.,
Alexei Podtelezhnikov <=