argument(s) | description |
object image | the image object to encode |
int bpp | bits per pixel, how many bits each pixel should take |
int vbpp | value bits per pixel; how many bits per pixel that really contains information |
int alignbits | the number of even bits each line should be padded to |
object colortable | colortable to get indices for pseudocolor |
string translate | translate table for colors. Length of this string should be 1<<vbpp (or 2<<vbpp if vbpp are greater than 8). |
encode_truecolor(img, 12,32, 0, 3,5, 4,0, 3,8)
will give (aligned to even 32 bits for each row):
0bbbrrr0 gggg0bbb rrr0gggg 0bbb...
<--pixel 1--><--pixel 2--> <--3-->
10987654 32101098 76543210 1098... <- bit position
<-><-> <-->
| | +--- 4,0: 4 bits green shifted 0 bits
| +-------- 3,5: 3 bits red shifted 5 bits
+----------- 3,8: 3 bits blue shifted 8 bits
The above call is equal to
encode_truecolor_masks(img, 12,32, 0, 224, 15, 768)
and
encode_truecolor(img, 12,32, 0, 3,5,4,0,3,8, colortable(1<<3,1<<4,1<<3)).
The latter gives possibility to use dither algorithms,
but is slightly slower.
argument(s) | description |
object image | the image object to encode |
int bpp | bits per pixel, how many bits each pixel should take |
int alignbits | the number of even bits each line should be padded to |
int rbits int gbits int bbits | bits for each basecolor |
int rshift int gshift int bshift | leftshifts for each basecolor |
int rmask int gmask int bmask | masks for each basecolor (xbits and gbits are calculated from this), needs to be massive (no zeroes among the ones in the mask). |
object ct | colortable object (for dithering, or whatever) |
int swapbytes | swap bytes for bpp==16,24,32, swaps bits in the bytes if bpp==1, for change of byte/bitorder between client and server. |