return 0;
}
+void swf_SetJPEGBits2(TAG * tag,U16 width,U16 height,RGBA* bitmap, int quality)
+{
+ JPEGBITS* jpeg;
+ int y;
+ jpeg = swf_SetJPEGBitsStart(tag,width,height,quality);
+ for (y=0;y<height;y++)
+ { U8 scanline[3*width];
+ int x,p = 0;
+ for (x=0;x<width;x++)
+ { scanline[p++] = bitmap[width*y+x].r;
+ scanline[p++] = bitmap[width*y+x].g;
+ scanline[p++] = bitmap[width*y+x].b;
+ }
+ swf_SetJPEGBitsLine(jpeg,scanline);
+ }
+ swf_SetJPEGBitsFinish(jpeg);
+}
+
int swf_SetJPEGBits(TAG * t,char * fname,int quality)
{ struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
}
else if(cinfo.out_color_space == JCS_YCbCr)
{
- //FIXME
- fprintf(stderr, "Error: Can't convert YCbCr(YUV) to RGB.\n");
- return -1;
+ for (y=0;y<cinfo.output_height;y++) {
+ int x;
+ for(x=0;x<cinfo.output_width;x++) {
+ int y = js[x*3+0];
+ int u = js[x*3+1];
+ int v = js[x*3+1];
+ // untested:
+ js[x*3+0] = y + ((360*(v-128))>>8);
+ js[x*3+1] = y - ((88*(u-128)-183*(v-128))>>8);
+ js[x*3+2] = y + ((455 * (u-128))>>8);
+ }
+ }
}
else if(cinfo.out_color_space == JCS_CMYK)
{
swf_SetU16(t,width);
swf_SetU16(t,height);
- if (data=malloc(OUTBUFFER_SIZE))
+ if ((data=malloc(OUTBUFFER_SIZE)))
{ z_stream zs;
memset(&zs,0x00,sizeof(z_stream));
swf_SetU16(t,height);
swf_SetU8(t,ncolors-1); // number of pal entries
- if (data=malloc(OUTBUFFER_SIZE))
+ if ((data=malloc(OUTBUFFER_SIZE)))
{ z_stream zs;
memset(&zs,0x00,sizeof(z_stream));
if (deflateInit(&zs,Z_DEFAULT_COMPRESSION)==Z_OK)
{ U8 * zpal; // compress palette
- if (zpal = malloc(ncolors*4))
+ if ((zpal = malloc(ncolors*4)))
{ U8 * pp = zpal;
int i;