Skip to content
Myr

realized the 2 colorbytes case is impossible.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

also updated the comment at the top of the file to reflect stbi_write_tga's new capabilities.

authored by Jean-S�bastien Guay · committed by Jean-S�bastien Guay · parent 26a71f6 · Browse files · 1 file+3 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−5 removed

  • other:+3 added−5 removed

1 file+3 added−5 removed

modified:stb_image_write.h+3 added-5 removed
40 unmodified lines
41 For PNG, "stride_in_bytes" is the distance in bytes from the first byte of42 a row of pixels to the first byte of the next row of pixels.4344 PNG creates output files with the same number of components as the input.45 The BMP and TGA formats expand Y to RGB in the file format. BMP does not45 The BMP format expands Y to RGB in the file format and does not46 output alpha.47 48 PNG supports writing rectangles of data even when the bytes storing rows of49 data are not consecutive in memory (e.g. sub-rectangles of a larger image),
77 unmodified lines
127 unsigned char *d = (unsigned char *) data + (j*x+i)*comp;128 if (write_alpha < 0)129 fwrite(&d[comp-1], 1, 1, f);130 switch (comp) {131 case 1: 131 case 1: fwrite(d, 1, 1, f);132 case 2: fwrite(d, 1, 1, f);133 break;133 case 2: fwrite(d, 2, 1, f);134 break;134 case 4:135 if (!write_alpha) {136 // composite against pink background137 for (k=0; k < 3; ++k)
42 unmodified lines
180{181 int has_alpha = !(comp & 1);182 int colorbytes = comp - has_alpha;183 int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3185 if (format == 2) colorbytes = 3; // is 2 color channels (RG/RGA) even possible? write as RGB/RGBA184 return outfile(filename, -1,-1, x, y, comp, (void *) data, has_alpha, 0,185 "111 221 2222 11", 0,0,format, 0,0,0, 0,0,x,y, (colorbytes+has_alpha)*8, has_alpha*8);186}187
332 unmodified lines