"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/imwrite.c" between
sip-0.5.6.tar.gz and sip-0.12.1.tar.gz

About: SIP (Scilab Image Processing) toolbox to do imaging tasks such as filtering, blurring, edge detection, thresholding, histogram manipulation, segmentation, mathematical morphology, color image processing, etc.

imwrite.c  (sip-0.5.6):imwrite.c  (sip-0.12.1)
skipping to change at line 47 skipping to change at line 47
*-----------------------------------------------------------------*/ *-----------------------------------------------------------------*/
SipExport int SipExport int
int_imwrite(char *fname) int_imwrite(char *fname)
{ {
/* Interface variables */ /* Interface variables */
int m1, n1, l1, int m1, n1, l1,
minlhs=1, maxlhs=1, minrhs=2, maxrhs=3, minlhs=1, maxlhs=1, minrhs=2, maxrhs=3,
name_rows, name_columns, name, name_rows, name_columns, name,
nopt, iopos; nopt, iopos;
static rhs_opts opts[]= { static rhs_opts opts[]= {
{-1,"depth","d",0,0,0}, {-1,"depth",-1,0,0,NULL},
{-1,"quality","d",0,0,0}, {-1,"quality",-1,0,0,NULL},
{-1,NULL,NULL,0,0,0} {-1,NULL,-1,0,0,NULL}
}; };
unsigned nv; unsigned nv;
bool stat; bool stat;
unsigned long depth, quality;
/* Other variables */ /* Other variables */
short int argtype; short int argtype;
/* ImageMagick variables */ /* ImageMagick variables */
ExceptionInfo exception; ExceptionInfo exception;
Image *image; Image *image;
ImageInfo *image_info; ImageInfo *image_info;
PixelPacket *pix; PixelPacket *pix;
/* -- Deal with the arguments -- */ /* -- Deal with the arguments -- */
nopt = NumOpt(); nopt = NumOpt();
CheckRhs(minrhs,maxrhs + nopt); CheckRhs(minrhs,maxrhs + nopt);
CheckLhs(minlhs,maxlhs); CheckLhs(minlhs,maxlhs);
if ( get_optionals(fname,opts) == 0) return false; if ( getOptionals(pvApiCtx,fname,opts) == 0) return false;
if ( (argtype = check_args(fname, nopt)) == false) return false; if ( (argtype = check_args(fname, nopt)) == false) return false;
/* default values if optional arguments are not given */ /* default values if optional arguments are not given */
iopos=Rhs ; iopos=Rhs ;
if ( opts[0].position == -1 ) { if ( opts[0].iPos == -1 ) {
iopos++; opts[0].position = iopos; depth = QuantumDepth;
opts[0].m = opts[0].n = 1; opts[0].type = "d"; } else {
CreateVar(opts[0].position,opts[0].type,&opts[0].m,&opts[0].n,&opts[0].l); double dblDepth = 0;
*stk(opts[0].l) = QuantumDepth; getScalarDouble(pvApiCtx, opts[0].piAddr, &dblDepth);
} else if ( *stk(opts[0].l) != 8) { depth = (unsigned long)dblDepth;
if (*stk(opts[0].l) == 16 && QuantumDepth < 16) if ( depth != 8) {
sip_error("depth cannot be 16 in your current setup") if (depth == 16 && QuantumDepth < 16)
else if (*stk(opts[0].l) != 16) sip_error("depth cannot be 16 in your current setup")
sip_error("depth must be 8 or 16") else if (depth != 16)
sip_error("depth must be 8 or 16")
}
}
if ( opts[1].iPos == -1 ) {
quality= 75; /* Default quality/compression for jpeg/png/miff */
} else {
double dblQuality = 0;
getScalarDouble(pvApiCtx, opts[1].piAddr, &dblQuality);
quality = (unsigned long) dblQuality;
if (dblQuality < 0 || quality > 100)
sip_error("quality must be in range 0-100")
} }
if ( opts[1].position == -1 ) {
iopos++; opts[1].position = iopos;
opts[1].m = opts[1].n = 1; opts[1].type = "d";
CreateVar(opts[1].position,opts[1].type,&opts[1].m,&opts[1].n,&opts[1].l);
*stk(opts[1].l)=75.0; /* Default quality/compression for jpeg/png/miff */
} else if ( *stk(opts[1].l) < 0 || *stk(opts[1].l) > 100)
sip_error("quality must be in range 0-100")
/* -- Pass scilab structures to IM -- */ /* -- Pass scilab structures to IM -- */
InitializeMagick(NULL); InitializeMagick(NULL);
GetExceptionInfo(&exception); GetExceptionInfo(&exception);
image_info=CloneImageInfo((ImageInfo *) NULL); image_info=CloneImageInfo((ImageInfo *) NULL);
image_info->colorspace = RGBColorspace; // @@@ maybe to take this off image_info->colorspace = RGBColorspace; // @@@ maybe to take this off
image_info->monochrome = 0; image_info->monochrome = 0;
image_info->dither = 0; // Imagemagick sets this as true by default. image_info->dither = 0; // Imagemagick sets this as true by default.
// But this changes binary images too much. // But this changes binary images too much.
image_info->depth= (unsigned long) *stk(opts[0].l); image_info->depth = depth;
image_info->quality= (unsigned long) *stk(opts[1].l); image_info->quality = quality;
image=AllocateImage(image_info); image=AllocateImage(image_info);
nv = 1; nv = 1;
switch (argtype) { switch (argtype) {
case ARG_2D: case ARG_2D:
GetRhsVar(nv++, "d", &m1, &n1, &l1); GetRhsVar(nv++, "d", &m1, &n1, &l1);
stat = sci_2D_double_matrix_to_magick(fname, l1, m1, n1, image, &pix ); stat = sci_2D_double_matrix_to_magick(fname, l1, m1, n1, image, &pix );
if (!stat) if (!stat)
return false; return false;
break; break;
 End of changes. 6 change blocks. 
23 lines changed or deleted 30 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS