Skip to content

Commit

Permalink
remove objectExtras from save(), unneeded
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Nov 1, 2023
1 parent 92a884f commit cc261b2
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 142 deletions.
2 changes: 1 addition & 1 deletion img/codec_X11.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
char * xc = fi-> io.fileName, * name;
int ls = ( i-> w >> 3) + (( i-> w & 7) ? 1 : 0);
int first = 1;
HV * profile = fi-> objectExtras;
HV * profile = fi-> extras;

l = malloc( ls);
if ( !l) return false;
Expand Down
2 changes: 1 addition & 1 deletion img/codec_Xpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
dPROFILE;
XpmInfo info;
XpmImage image;
HV * profile = fi-> objectExtras;
HV * profile = fi-> extras;
PIcon i = ( PIcon) fi-> object;
int ret = XpmOpenFailed;
char * extholder = NULL;
Expand Down
2 changes: 1 addition & 1 deletion img/codec_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
{
dPROFILE;
PImage i = ( PImage) fi-> object;
HV * profile = fi-> objectExtras;
HV * profile = fi-> extras;
int cRGB;
PImgIORequest fd = fi-> req;
RGBColor rgb_1bpp[2], * palette = i-> palette;
Expand Down
2 changes: 1 addition & 1 deletion img/codec_gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
dPROFILE;
GifFileType * g = ( GifFileType *) fi-> instance;
PImage i = ( PImage) fi-> object;
HV * profile = fi-> objectExtras;
HV * profile = fi-> extras;

if ( fi-> frame == 0) {
/* put screen description */
Expand Down
4 changes: 2 additions & 2 deletions img/codec_heif.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ static Bool
apply_encoder_options( PImgSaveFileInstance fi, enum heif_compression_format compression, struct heif_encoder* encoder)
{
SV **tmp;
HV * profile = fi-> objectExtras;
HV * profile = fi-> extras;
SaveRec * l = ( SaveRec *) fi-> instance;
const struct heif_encoder_parameter*const* list;
const char * shrt = NULL, * enc_name;
Expand Down Expand Up @@ -922,7 +922,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
dPROFILE;
SaveRec * l = ( SaveRec *) fi-> instance;
struct heif_encoder* encoder = NULL;
HV * profile = fi-> objectExtras;
HV * profile = fi-> extras;
enum heif_compression_format compression;
struct heif_image* himg = NULL;
PIcon i = ( PIcon) fi-> object;
Expand Down
2 changes: 1 addition & 1 deletion img/codec_jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
i = ( PImage) fi-> object;
l = ( SaveRec *) fi-> instance;
appdata = NULL;
profile = fi-> objectExtras;
profile = fi-> extras;

l-> c. image_width = i-> w;
l-> c. image_height = i-> h;
Expand Down
14 changes: 5 additions & 9 deletions img/codec_png.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ typedef struct _SaveRec {
png_structp png_ptr;
png_infop info_ptr;
Byte * line;
Bool icon, autoConvert;
Bool icon;
int m_type, m_mask, m_palSize;
RGBColor m_palette[256];
png_byte m_dataPLTE[12 + 256 * 3];
Expand Down Expand Up @@ -1447,7 +1447,7 @@ write_IHDR(PImgSaveFileInstance fi)
if ( s->icon && i-> autoMasking != amMaskIndex && i-> autoMasking != amMaskColor ) {
/* png doesn't support paletted images with alpha channel? */
if ( color_type == PNG_COLOR_TYPE_PALETTE) {
if ( !s->autoConvert)
if ( !fi->autoConvert)
outc("Cannot apply alpha channel to a paletted image");
CImage( i)-> set_type(( Handle) i, imRGB);
if ( i-> type != imRGB)
Expand All @@ -1457,7 +1457,7 @@ write_IHDR(PImgSaveFileInstance fi)

/* and does not alpha with bit_depth other that 8 or 24 bits? */
if ( bit_depth != 8) {
if ( !s->autoConvert)
if ( !fi->autoConvert)
outc( "Image depth must be of 8 bits to be saved with alpha channel");
CImage( i)-> set_type(( Handle) i, imbpp8 | ( i-> type & imGrayScale));
if (( i-> type & imBPP) != 8)
Expand All @@ -1466,7 +1466,7 @@ write_IHDR(PImgSaveFileInstance fi)
}

if ( i-> maskType != imbpp8) {
if ( !s->autoConvert)
if ( !fi->autoConvert)
outc("maskType is not of type im::bpp8");
i-> self-> set_maskType( fi-> object, imbpp8);
if ( i-> maskType != imbpp8 )
Expand Down Expand Up @@ -1907,7 +1907,7 @@ write_fcTL(PImgSaveFileInstance fi)
(s->icon && i->maskType != s->m_mask) ||
(s->m_palSize > 0 && memcmp( s-> m_palette, i-> palette, i-> palSize * 3) != 0)
) {
if ( s->autoConvert ) {
if ( fi->autoConvert ) {
if (
i->type != s->m_type ||
(s->m_palSize > 0 && memcmp( s-> m_palette, i-> palette, i-> palSize * 3) != 0)
Expand Down Expand Up @@ -2149,13 +2149,9 @@ write_classic_png(PImgSaveFileInstance fi)
static Bool
save( PImgCodec instance, PImgSaveFileInstance fi)
{
dPROFILE;
HV * profile = fi-> extras;
SaveRec * s = ( SaveRec *) fi-> instance;

s-> icon = kind_of( fi-> object, CIcon);
/* recognize autoConvert as the image subsystem does */
s->autoConvert = pexist( autoConvert) ? pget_B( autoConvert) : true;

if ( setjmp( png_jmpbuf( s-> png_ptr)) != 0) return false;

Expand Down
2 changes: 1 addition & 1 deletion img/codec_tiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
TIFF * tiff = ( TIFF*) fi-> instance;
Bool icon = kind_of( fi-> object, CIcon);
int x, y;
HV * profile = fi-> objectExtras;
HV * profile = fi-> extras;
uint16_t u16;

errbuf = fi-> errbuf;
Expand Down
2 changes: 1 addition & 1 deletion img/codec_webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ save( PImgCodec instance, PImgSaveFileInstance fi)
s = ( SaveRec *) fi-> instance;
icon = kind_of( fi-> object, CIcon);
i = ( PIcon) fi-> object;
profile = fi-> objectExtras;
profile = fi-> extras;

/* settings */
if ( fi-> frame == 0)
Expand Down
Loading

0 comments on commit cc261b2

Please sign in to comment.