added support for gradient rendering
[swftools.git] / lib / modules / swfbits.c
index bbd8641..4510c48 100644 (file)
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include "../../config.h"
+#ifdef HAVE_ZLIB
+#include <zconf.h>
+#include <zlib.h>
+#endif
+#include <fcntl.h>
+#include <ctype.h>
+
+#ifdef HAVE_JPEGLIB
+#define HAVE_BOOLEAN
 #ifdef __cplusplus
 extern "C" {
 #endif
-#include "jpeglib.h"
+#include <jpeglib.h>
 #ifdef __cplusplus
 }
 #endif
+#endif // HAVE_JPEGLIB
+
+#include "../rfxswf.h"
 
 #define OUTBUFFER_SIZE 0x8000
 
@@ -289,8 +305,8 @@ void swf_SetJPEGBits2(TAG * tag, U16 width, U16 height, RGBA * bitmap,
     JPEGBITS *jpeg;
     int y;
     jpeg = swf_SetJPEGBitsStart(tag, width, height, quality);
+       U8 *scanline = (U8*)rfx_alloc(3 * width);
     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;
@@ -299,6 +315,7 @@ void swf_SetJPEGBits2(TAG * tag, U16 width, U16 height, RGBA * bitmap,
        }
        swf_SetJPEGBitsLine(jpeg, scanline);
     }
+    rfx_free(scanline);
     swf_SetJPEGBitsFinish(jpeg);
 }
 
@@ -1060,8 +1077,8 @@ int swf_SetJPEGBits3(TAG * tag, U16 width, U16 height, RGBA * bitmap, int qualit
     pos = tag->len;
     swf_SetU32(tag, 0);                //placeholder
     jpeg = swf_SetJPEGBitsStart(tag, width, height, quality);
+       U8 *scanline = (U8*)rfx_alloc(3 * width);
     for (y = 0; y < height; y++) {
-       U8 scanline[3 * width];
        int x, p = 0;
        for (x = 0; x < width; x++) {
            //int ia = bitmap[width*y+x].a;
@@ -1078,6 +1095,7 @@ int swf_SetJPEGBits3(TAG * tag, U16 width, U16 height, RGBA * bitmap, int qualit
        }
        swf_SetJPEGBitsLine(jpeg, scanline);
     }
+    rfx_free(scanline);
     swf_SetJPEGBitsFinish(jpeg);
     PUT32(&tag->data[pos], tag->len - pos - 4);
 
@@ -1092,8 +1110,8 @@ int swf_SetJPEGBits3(TAG * tag, U16 width, U16 height, RGBA * bitmap, int qualit
     zs.next_out = data;
     zs.avail_out = OUTBUFFER_SIZE;
 
+       scanline = (U8*)rfx_alloc(width);
     for (y = 0; y < height; y++) {
-       U8 scanline[width];
        int x, p = 0;
        for (x = 0; x < width; x++) {
            scanline[p++] = bitmap[width * y + x].a;
@@ -1117,6 +1135,8 @@ int swf_SetJPEGBits3(TAG * tag, U16 width, U16 height, RGBA * bitmap, int qualit
        }
     }
 
+    rfx_free(scanline);
+
     while (1) {
        int ret = deflate(&zs, Z_FINISH);
        if (ret != Z_OK && ret != Z_STREAM_END) {