/* if the data contains an alpha layer (a != 255), the
r,g,b values will have to be premultiplied */
gfxcolor_t*data;
- int width;
- int height;
+ unsigned width;
+ unsigned height;
} gfximage_t;
/* gradients: A radial gradient will start at 0,0 and have a radius of 1,0
TAG * tag;
RGBA* pic, *pic2, rgb;
SWFPLACEOBJECT obj;
- int width = 0;
- int height = 0;
+ unsigned width = 0;
+ unsigned height = 0;
int frames = 10;
int framerate = 29;
unsigned char*data;
dmgr->free_in_buffer = 0;
}
-int jpeg_save(unsigned char*data, int width, int height, int quality, const char*filename)
+int jpeg_save(unsigned char*data, unsigned width, unsigned height, int quality, const char*filename)
{
struct jpeg_destination_mgr mgr;
struct jpeg_compress_struct cinfo;
return 1;
}
-int jpeg_save_gray(unsigned char*data, int width, int height, int quality, const char*filename)
+int jpeg_save_gray(unsigned char*data, unsigned width, unsigned height, int quality, const char*filename)
{
struct jpeg_destination_mgr mgr;
struct jpeg_compress_struct cinfo;
}
-int jpeg_save_to_file(unsigned char*data, int width, int height, int quality, FILE*_fi)
+int jpeg_save_to_file(unsigned char*data, unsigned width, unsigned height, int quality, FILE*_fi)
{
struct jpeg_destination_mgr mgr;
struct jpeg_compress_struct cinfo;
return 1;
}
-int jpeg_save_to_mem(unsigned char*data, int width, int height, int quality, unsigned char*_dest, int _destlen)
+int jpeg_save_to_mem(unsigned char*data, unsigned width, unsigned height, int quality, unsigned char*_dest, int _destlen)
{
struct jpeg_destination_mgr mgr;
struct jpeg_compress_struct cinfo;
//printf("term %d\n", size - mgr->bytes_in_buffer);
}
-int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char**dest, int*width, int*height)
+int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char**dest, unsigned*width, unsigned*height)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
typedef unsigned char U8;
-int jpeg_load(const char*filename, unsigned char**dest, int*_width, int*_height)
+int jpeg_load(const char*filename, unsigned char**dest, unsigned*_width, unsigned*_height)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
U8*scanline = (U8 *)malloc(4 * cinfo.output_width);
- int width = *_width = cinfo.output_width;
- int height = *_height = cinfo.output_height;
- *dest = (unsigned char*)malloc(width*height*4);
+ unsigned int width = *_width = cinfo.output_width;
+ unsigned int height = *_height = cinfo.output_height;
+ unsigned long long int image_size = (unsigned long long)width * height * 4;
+ if(image_size > 0xffffffff) {
+ *_width = 0;
+ *_height = 0;
+ return 0;
+ }
+ *dest = (unsigned char*)malloc(image_size);
int y;
for (y=0;y<height;y++) {
return 1;
}
-void jpeg_get_size(const char *filename, int *width, int *height)
+void jpeg_get_size(const char *filename, unsigned *width, unsigned*height)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
#else
-int jpeg_save(unsigned char*data, int width, int height, int quality, const char*filename)
+int jpeg_save(unsigned char*data, unsigned width, unsigned height, int quality, const char*filename)
{
fprintf(stderr, "jpeg_save: No JPEG support compiled in\n");
return 0;
}
-int jpeg_save_to_file(unsigned char*data, int width, int height, int quality, FILE*fi)
+int jpeg_save_to_file(unsigned char*data, unsigned width, unsigned height, int quality, FILE*fi)
{
fprintf(stderr, "jpeg_save_to_file: No JPEG support compiled in\n");
return 0;
}
-int jpeg_save_to_mem(unsigned char*data, int width, int height, int quality, unsigned char*dest, int destsize)
+int jpeg_save_to_mem(unsigned char*data, unsigned width, unsigned height, int quality, unsigned char*dest, int destsize)
{
fprintf(stderr, "jpeg_save_tomem: No JPEG support compiled in\n");
return 0;
}
-int jpeg_load_from_mem(unsigned char*_data, int size, unsigned char*dest, int width, int height)
+int jpeg_load_from_mem(unsigned char*_data, int size, unsigned char*dest, unsigned width, unsigned height)
{
fprintf(stderr, "jpeg_load_from_mem: No JPEG support compiled in\n");
return 0;
}
-int jpeg_load(const char*filename, unsigned char**dest, int*_width, int*_height)
+int jpeg_load(const char*filename, unsigned char**dest, unsigned*_width, unsigned*_height)
{
fprintf(stderr, "jpeg_load: No JPEG support compiled in\n");
return 0;
}
-void jpeg_get_size(const char *fname, int *width, int *height)
+void jpeg_get_size(const char *fname, unsigned *width, unsigned *height)
{
*width = 0;
*height = 0;
extern "C" {
#endif
-int jpeg_save(unsigned char*data, int width, int height, int quality, const char*filename);
-int jpeg_save_gray(unsigned char*data, int width, int height, int quality, const char*filename);
-int jpeg_save_to_file(unsigned char*data, int width, int height, int quality, FILE*fi);
-int jpeg_save_to_mem(unsigned char*data, int width, int height, int quality, unsigned char*dest, int destsize);
-int jpeg_load(const char*filename, unsigned char**dest, int*width, int*height);
-int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char**dest, int*width, int*height);
-void jpeg_get_size(const char *fname, int *width, int *height);
+int jpeg_save(unsigned char*data, unsigned int width, unsigned int height, int quality, const char*filename);
+int jpeg_save_gray(unsigned char*data, unsigned int width, unsigned int height, int quality, const char*filename);
+int jpeg_save_to_file(unsigned char*data, unsigned int width, unsigned int height, int quality, FILE*fi);
+int jpeg_save_to_mem(unsigned char*data, unsigned int width, unsigned int height, int quality, unsigned char*dest, int destsize);
+int jpeg_load(const char*filename, unsigned char**dest, unsigned int*width, unsigned int*height);
+int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char**dest, unsigned int*width, unsigned int*height);
+void jpeg_get_size(const char *fname, unsigned int *width, unsigned int *height);
#ifdef __cplusplus
}
RGBA col;
double xx = ( (x - rx) * m22 - (y - ry) * m21)*det;
double yy = (- (x - rx) * m12 + (y - ry) * m11)*det;
- int ainv;
- ainv = 255-col.a;
if(type == FILL_LINEAR) {
int xr = xx*256;
xr = 511;
col = palette[xr];
}
-
+ int ainv;
+ ainv = 255-col.a;
line[x].r = clamp(((line[x].r*ainv)>>8)+col.r);
line[x].g = clamp(((line[x].g*ainv)>>8)+col.g);
line[x].b = clamp(((line[x].b*ainv)>>8)+col.b);
struct png_header
{
- int width;
- int height;
+ unsigned width;
+ unsigned height;
int bpp;
int mode;
};
else return c;
}
-static void applyfilter1(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, int width)
+static void applyfilter1(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, unsigned width)
{
int x;
unsigned char last=0;
}
-static void applyfilter2(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, int width)
+static void applyfilter2(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, unsigned width)
{
int x;
unsigned char lasta=0;
/* also performs 24 bit conversion! */
-static void applyfilter3(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, int width)
+static void applyfilter3(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, unsigned width)
{
int x;
unsigned char lastr=0;
}
}
-void png_inverse_filter_32(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, int width)
+void png_inverse_filter_32(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, unsigned width)
{
int x;
unsigned char lastr=0;
}
}
-EXPORT int getPNGdimensions(const char*sname, int*destwidth, int*destheight)
+EXPORT int getPNGdimensions(const char*sname, unsigned*destwidth, unsigned*destheight)
{
FILE*fi;
struct png_header header;
return 1;
}
-EXPORT int getPNG(const char*sname, int*destwidth, int*destheight, unsigned char**destdata)
+EXPORT int getPNG(const char*sname, unsigned*destwidth, unsigned*destheight, unsigned char**destdata)
{
char tagid[4];
int len;
unsigned char*data;
unsigned char*imagedata;
unsigned char*zimagedata=0;
- unsigned long int imagedatalen;
unsigned long int zimagedatalen=0;
unsigned char*palette = 0;
int palettelen = 0;
return 0;
}
- imagedatalen = bypp * header.width * header.height + 65536;
+ unsigned long long imagedatalen_64 = ((unsigned long long)header.width + 1) * header.height * bypp;
+ if(imagedatalen_64 > 0xffffffff)
+ return 0;
+ unsigned long imagedatalen = (unsigned long)imagedatalen_64;
imagedata = (unsigned char*)malloc(imagedatalen);
fseek(fi,8,SEEK_SET);
return hash;
}
-static int png_get_number_of_palette_entries(COL*img, int width, int height, COL*palette, char*has_alpha)
+static int png_get_number_of_palette_entries(COL*img, unsigned width, unsigned height, COL*palette, char*has_alpha)
{
int len = width*height;
int t;
}
}
-static int png_apply_specific_filter_8(int filtermode, unsigned char*dest, unsigned char*src, int width)
+static int png_apply_specific_filter_8(int filtermode, unsigned char*dest, unsigned char*src, unsigned width)
{
int pos2 = 0;
int pos = 0;
- int srcwidth = width;
+ unsigned srcwidth = width;
int x;
if(filtermode == 0) {
for(x=0;x<width;x++) {
return filtermode;
}
-static int png_apply_specific_filter_32(int filtermode, unsigned char*dest, unsigned char*src, int width)
+static int png_apply_specific_filter_32(int filtermode, unsigned char*dest, unsigned char*src, unsigned width)
{
int pos2 = 0;
int pos = 0;
- int srcwidth = width*4;
+ unsigned srcwidth = width*4;
int x;
if(filtermode == 0) {
for(x=0;x<width;x++) {
}
}
-static int png_find_best_filter(unsigned char*src, int width, int bpp, int y)
+static int png_find_best_filter(unsigned char*src, unsigned width, int bpp, int y)
{
make_num_bits_table();
}
-static int png_apply_filter(unsigned char*dest, unsigned char*src, int width, int y, int bpp)
+static int png_apply_filter(unsigned char*dest, unsigned char*src, unsigned width, int y, int bpp)
{
int best_nr = 0;
#if 0
return best_nr;
}
-int png_apply_filter_8(unsigned char*dest, unsigned char*src, int width, int y)
+int png_apply_filter_8(unsigned char*dest, unsigned char*src, unsigned width, int y)
{
return png_apply_filter(dest, src, width, y, 8);
}
-int png_apply_filter_32(unsigned char*dest, unsigned char*src, int width, int y)
+int png_apply_filter_32(unsigned char*dest, unsigned char*src, unsigned width, int y)
{
return png_apply_filter(dest, src, width, y, 32);
}
-EXPORT void savePNG(const char*filename, unsigned char*data, int width, int height, int numcolors)
+EXPORT void savePNG(const char*filename, unsigned char*data, unsigned width, unsigned height, int numcolors)
{
FILE*fi;
int crc;
{
int x,y;
int bypp = bpp/8;
- int srcwidth = width * bypp;
- int linelen = 1 + srcwidth;
+ unsigned srcwidth = width * bypp;
+ unsigned linelen = 1 + srcwidth;
if(bypp==2)
linelen = 1 + ((srcwidth+1)&~1);
else if(bypp==3)
fclose(fi);
}
-EXPORT void writePNG(const char*filename, unsigned char*data, int width, int height)
+EXPORT void writePNG(const char*filename, unsigned char*data, unsigned width, unsigned height)
{
savePNG(filename, data, width, height, 0);
}
-EXPORT void writePalettePNG(const char*filename, unsigned char*data, int width, int height)
+EXPORT void writePalettePNG(const char*filename, unsigned char*data, unsigned width, unsigned height)
{
savePNG(filename, data, width, height, 256);
}
extern "C" {
#endif
-int png_apply_filter_32(unsigned char*dest, unsigned char*src, int width, int y);
-void png_inverse_filter_32(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, int width);
+int png_apply_filter_32(unsigned char*dest, unsigned char*src, unsigned width, int y);
+void png_inverse_filter_32(int mode, unsigned char*src, unsigned char*old, unsigned char*dest, unsigned width);
-int getPNG(const char*sname, int*destwidth, int*destheight, unsigned char**destdata);
-int getPNGdimensions(const char*sname, int*destwidth, int*destheight);
+int getPNG(const char*sname, unsigned*destwidth, unsigned*destheight, unsigned char**destdata);
+int getPNGdimensions(const char*sname, unsigned*destwidth, unsigned*destheight);
-void savePNG(const char*filename, unsigned char*data, int width, int height, int numcolors);
+void savePNG(const char*filename, unsigned char*data, unsigned width, unsigned height, int numcolors);
-void writePNG(const char*filename, unsigned char*data, int width, int height);
-void writePalettePNG(const char*filename, unsigned char*data, int width, int height);
+void writePNG(const char*filename, unsigned char*data, unsigned width, unsigned height);
+void writePalettePNG(const char*filename, unsigned char*data, unsigned width, unsigned height);
#ifdef __cplusplus
}
memset(i, 0, sizeof(image_doc_internal_t));
gfxcolor_t*data = 0;
- int width = 0;
- int height = 0;
+ unsigned width = 0;
+ unsigned height = 0;
if(!getPNG(filename, &width, &height, (unsigned char**)&data)) {
if(!jpeg_load(filename, (unsigned char**)&data, &width, &height)) {
MATRIX m;
int fs;
- int width=0, height=0;
+ unsigned width=0, height=0;
#ifndef HAVE_JPEGLIB
if(global.mkjpeg) {
/* step 1: the bitmap */
SRECT r;
int imageID = id;
- int width, height;
+ unsigned width, height;
if(!strcmp(type,"jpeg")) {
#ifndef HAVE_JPEGLIB
warning("no jpeg support compiled in");
memmove(&tag->data[pos], &tag->data[pos+4], end-(pos+4));
}
unsigned char*image;
- int width=0, height=0;
+ unsigned width=0, height=0;
jpeg_load_from_mem(&tag->data[6], end-6, &image, &width, &height);
uLongf datalen = width*height;