- /* 24->32 bit conversion */
- for(i=0;i<palettelen;i++) {
- rgba[i].r = palette[i*3+0];
- rgba[i].g = palette[i*3+1];
- rgba[i].b = palette[i*3+2];
- if(alphapalette && i<alphapalettelen) {
- rgba[i].a = alphapalette[i];
- if(alphapalette[i] == 0) {
- /* if the color is fully transparent, it doesn't matter
- what it's rgb values are. furthermore, all Flash
- players up to Flash 5 can't deal with anything beyond
- one transparent color with value (00,00,00,00). */
- rgba[i].r = rgba[i].g = rgba[i].b = 0;
- }
- } else {
- rgba[i].a = 255;
- }
- }
-
- for(y=0;y<header.height;y++) {
- int mode = imagedata[pos++]; //filter mode
- U8*old;
- U8*dest = &data2[y*swf_width];
- U8*src;
- src = &imagedata[pos];
- if(header.bpp == 8) {
- pos+=header.width;
- } else {
- int x,s=0;
- int bitpos = 0;
- U32 v = (1<<header.bpp)-1;
- for(x=0;x<header.width;x++) {
- U32 r = src[s/8]<<8 |
- src[s/8+1];
- int t;
- tmpline[x] = (r>>(16-header.bpp-(s&7)))&v;
- s+=header.bpp;
- }
- src = tmpline;
- pos+=(header.width*header.bpp+7)/8;
- }
-
- if(!y) {
- memset(data2,0,swf_width);
- old = &data2[y*swf_width];
- } else {
- old = &data2[(y-1)*swf_width];
- }
- applyfilter1(mode, src, old, dest, header.width);
- }
- swf_SetLosslessBitsIndexed(t, header.width, header.height, data2, rgba, palettelen);
- free(tmpline);
- free(rgba);
- free(data2);
+#endif
+ } else {
+ RGBA*data = 0;
+ png_load(sname, &width, &height, (unsigned char**)&data);
+ if(!data)
+ exit(1);
+ t = swf_InsertTag(t, ST_DEFINEBITSLOSSLESS);
+ swf_SetU16(t, id);
+ swf_SetLosslessImage(t, data,width,height);