image.c (ziproxy-3.3.1) | : | image.c (ziproxy-3.3.2.tar.bz2) | ||
---|---|---|---|---|
/* image.c | /* image.c | |||
* Image reading/writing wrappers. | * Image reading/writing wrappers. | |||
* | * | |||
* Ziproxy - the HTTP acceleration proxy | * Ziproxy - the HTTP acceleration proxy | |||
* This code is under the following conditions: | * This code is under the following conditions: | |||
* | * | |||
* --------------------------------------------------------------------- | * --------------------------------------------------------------------- | |||
* Copyright (c)2005-2014 Daniel Mealha Cabrita | * Copyright (c)2005-2021 Daniel Mealha Cabrita | |||
* | * | |||
* This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | |||
* (at your option) any later version. | * (at your option) any later version. | |||
* | * | |||
* This program is distributed in the hope that it will be useful, | * This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | * GNU General Public License for more details. | |||
skipping to change at line 903 | skipping to change at line 903 | |||
const int InterlacedJumps[] = { 8, 8, 4, 2 }; /* be read - offsets and jumps... */ | const int InterlacedJumps[] = { 8, 8, 4, 2 }; /* be read - offsets and jumps... */ | |||
raw_bitmap *bmp; | raw_bitmap *bmp; | |||
unsigned char *MyColorMap = NULL; | unsigned char *MyColorMap = NULL; | |||
int MyColorCount = -1; | int MyColorCount = -1; | |||
long long int raw_size; | long long int raw_size; | |||
desc.buf=inbuf; | desc.buf=inbuf; | |||
desc.size=insize; | desc.size=insize; | |||
desc.x.pos=0; | desc.x.pos=0; | |||
#if GIFLIB_MAJOR >= 5 | ||||
if ((GifFile = DGifOpen((void*)&desc, &gif_mem_input, NULL)) == NULL) | ||||
#else | ||||
if ((GifFile = DGifOpen((void*)&desc, &gif_mem_input)) == NULL) | if ((GifFile = DGifOpen((void*)&desc, &gif_mem_input)) == NULL) | |||
#endif | ||||
return( IMG_RET_ERR_UNKNOWN + IMG_RET_FLG_WHILE_DECOMP);//more po ssible reasons | return( IMG_RET_ERR_UNKNOWN + IMG_RET_FLG_WHILE_DECOMP);//more po ssible reasons | |||
bmp = new_raw_bitmap(); | bmp = new_raw_bitmap(); | |||
*out = bmp; | *out = bmp; | |||
bmp->width=GifFile->SWidth; | bmp->width=GifFile->SWidth; | |||
bmp->height=GifFile->SHeight; | bmp->height=GifFile->SHeight; | |||
/* MaxUncompressedImageRatio checking */ | /* MaxUncompressedImageRatio checking */ | |||
/* this is an estimation of the bitmap size used in memory, | /* this is an estimation of the bitmap size used in memory, | |||
it assumes 8 bits per pixel. | it assumes 8 bits per pixel. | |||
skipping to change at line 1079 | skipping to change at line 1083 | |||
}else{ | }else{ | |||
if(MyColorMap) for(i =0; i< bmp->width*bmp->height; i++){ | if(MyColorMap) for(i =0; i< bmp->width*bmp->height; i++){ | |||
Raster[i]=MyColorMap[Raster[i]] - 1; | Raster[i]=MyColorMap[Raster[i]] - 1; | |||
} | } | |||
bmp->raster = Raster; | bmp->raster = Raster; | |||
} | } | |||
bmp->pal_bpp = bmp->bpp; | bmp->pal_bpp = bmp->bpp; | |||
#if GIFLIB_MAJOR >= 5 | ||||
DGifCloseFile(GifFile, NULL); | ||||
#else | ||||
DGifCloseFile(GifFile); | DGifCloseFile(GifFile); | |||
#endif | ||||
return IMG_RET_OK; | return IMG_RET_OK; | |||
} | } | |||
IODesc * get_src (IODesc* ptr) | IODesc * get_src (IODesc* ptr) | |||
{ | { | |||
static IODesc *myptr; | static IODesc *myptr; | |||
if (ptr != NULL) myptr = ptr; | if (ptr != NULL) myptr = ptr; | |||
return myptr; | return myptr; | |||
} | } | |||
skipping to change at line 1734 | skipping to change at line 1742 | |||
// initialize components | // initialize components | |||
for (cmptno = 0, cmptparm = cmptparms; cmptno < bmp->bpp; ++cmptno, ++cmp tparm) { | for (cmptno = 0, cmptparm = cmptparms; cmptno < bmp->bpp; ++cmptno, ++cmp tparm) { | |||
cmptparm->tlx = csampling_effective [(cmptno * 4) + 0]; // 0 = ma x quality | cmptparm->tlx = csampling_effective [(cmptno * 4) + 0]; // 0 = ma x quality | |||
cmptparm->tly = csampling_effective [(cmptno * 4) + 1]; // 0 = ma x quality | cmptparm->tly = csampling_effective [(cmptno * 4) + 1]; // 0 = ma x quality | |||
cmptparm->hstep = csampling_effective [(cmptno * 4) + 2]; // 1 = max quality | cmptparm->hstep = csampling_effective [(cmptno * 4) + 2]; // 1 = max quality | |||
cmptparm->vstep = csampling_effective [(cmptno * 4) + 3]; // 1 = max quality | cmptparm->vstep = csampling_effective [(cmptno * 4) + 3]; // 1 = max quality | |||
cmptparm->width = cwidth [cmptno]; | cmptparm->width = cwidth [cmptno]; | |||
cmptparm->height = cheight [cmptno]; | cmptparm->height = cheight [cmptno]; | |||
cmptparm->prec = cbitlen [cmptno]; | cmptparm->prec = cbitlen [cmptno]; | |||
#if GIFLIB_MAJOR >= 5 | ||||
cmptparm->sgnd = 0; // we only generate unsigned components | ||||
#else | ||||
cmptparm->sgnd = false; // we only generate unsigned components | cmptparm->sgnd = false; // we only generate unsigned components | |||
#endif | ||||
cshiftR [cmptno] = 8 - cbitlen [cmptno]; // calculate the resampl ing shift for this component | cshiftR [cmptno] = 8 - cbitlen [cmptno]; // calculate the resampl ing shift for this component | |||
} | } | |||
if ((jimg = jas_image_create (bmp->bpp, cmptparms, JAS_CLRSPC_UNKNOWN)) = = NULL) | if ((jimg = jas_image_create (bmp->bpp, cmptparms, JAS_CLRSPC_UNKNOWN)) = = NULL) | |||
return IMG_RET_ERR_UNKNOWN; // unable to create image | return IMG_RET_ERR_UNKNOWN; // unable to create image | |||
// initialize image parameters | // initialize image parameters | |||
// FIXME: this does not work, libjasper always 'guess' the width/height b ased on the components' dimensions | // FIXME: this does not work, libjasper always 'guess' the width/height b ased on the components' dimensions | |||
// unfortunately certain combinations of components' dimensions ma ke libjasper output a slightly smaller picture | // unfortunately certain combinations of components' dimensions ma ke libjasper output a slightly smaller picture | |||
End of changes. 7 change blocks. | ||||
1 lines changed or deleted | 13 lines changed or added |