@@ -62,6 +62,7 @@ ImageInfo imageInfo[] =
62
62
{
63
63
IMAGE_INFO_ENTRY (RGB565 , 2 ),
64
64
IMAGE_INFO_ENTRY (RGB888 , 3 ),
65
+ IMAGE_INFO_ENTRY (RGBA16 , 2 ),
65
66
IMAGE_INFO_ENTRY (RGBA32 , 4 )
66
67
};
67
68
@@ -131,6 +132,50 @@ pngWriteImageRGB888(
131
132
132
133
//-----------------------------------------------------------------------
133
134
135
+ void
136
+ pngWriteImageRGBA16 (
137
+ int width ,
138
+ int height ,
139
+ int pitch ,
140
+ void * buffer ,
141
+ png_structp pngPtr ,
142
+ png_infop infoPtr )
143
+ {
144
+ int rowLength = 3 * width ;
145
+ uint8_t * imageRow = malloc (rowLength );
146
+
147
+ if (imageRow == NULL )
148
+ {
149
+ fprintf (stderr , "%s: unable to allocated row buffer\n" , program );
150
+ exit (EXIT_FAILURE );
151
+ }
152
+
153
+ int y = 0 ;
154
+ for (y = 0 ; y < height ; y ++ )
155
+ {
156
+ int x = 0 ;
157
+ for (x = 0 ; x < width ; x ++ )
158
+ {
159
+ uint16_t pixels = * (uint16_t * )(buffer + (y * pitch ) + (x * 2 ));
160
+ int index = x * 3 ;
161
+
162
+ uint8_t r4 = (pixels >> 12 ) & 0xF ;
163
+ uint8_t g4 = (pixels >> 8 ) & 0xF ;
164
+ uint8_t b4 = (pixels >> 4 ) & 0xF ;
165
+
166
+ imageRow [index ] = (r4 << 4 ) | r4 ;
167
+ imageRow [index + 1 ] = (g4 << 4 ) | g4 ;
168
+ imageRow [index + 2 ] = (b4 << 4 ) | b4 ;
169
+ }
170
+ png_write_row (pngPtr , imageRow );
171
+
172
+ }
173
+
174
+ free (imageRow );
175
+ }
176
+
177
+ //-----------------------------------------------------------------------
178
+
134
179
void
135
180
pngWriteImageRGBA32 (
136
181
int width ,
@@ -516,6 +561,16 @@ int main(int argc, char *argv[])
516
561
infoPtr );
517
562
break ;
518
563
564
+ case VC_IMAGE_RGBA16 :
565
+
566
+ pngWriteImageRGBA16 (width ,
567
+ height ,
568
+ pitch ,
569
+ dmxImagePtr ,
570
+ pngPtr ,
571
+ infoPtr );
572
+ break ;
573
+
519
574
case VC_IMAGE_RGBA32 :
520
575
521
576
pngWriteImageRGBA32 (width ,
0 commit comments