int InitImportObscuredEvent(XParms xp, Parms p, int reps) { flo = ( XiePhotoflo ) NULL; flograph = ( XiePhotoElement * ) NULL; flo_elements = 2; flograph = XieAllocatePhotofloGraph(flo_elements); if ( flograph == ( XiePhotoElement * ) NULL ) { fprintf( stderr, "XieAllocatePhotofloGraph failed\n" ); reps = 0; } else { XieFloImportDrawable(&flograph[0], xp->w, 0, 0, WIDTH, HEIGHT, 0, True ); XieFloExportDrawable(&flograph[1], 1, /* source phototag number */ drawableWindow, xp->fggc, 0, /* x offset in window */ 0 /* y offset in window */ ); XMoveWindow( xp->d, drawableWindow, 100, 100 ); XMapRaised( xp->d, drawableWindow ); XSync( xp->d, 0 ); GetXIEWindow( xp, p, xp->w, 1 ); dontClear = True; flo = XieCreatePhotoflo( xp->d, flograph, 2 ); } if ( !reps ) { XUnmapWindow( xp->d, drawableWindow ); FreeImportObscuredEventStuff( xp, p ); } return( reps ); }
int InitPhotofloDoneEvent(XParms xp, Parms p, int reps) { XIEPhotomap = ( XiePhotomap ) NULL; flo = ( XiePhotoflo ) NULL; flograph = ( XiePhotoElement * ) NULL; if ( ( XIEPhotomap = GetXIEDitheredPhotomap( xp, p, 1, (1 << xp->vinfo.depth ) ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { flo_elements = 2; flograph = XieAllocatePhotofloGraph(flo_elements); if ( flograph == ( XiePhotoElement * ) NULL ) { fprintf( stderr, "XieAllocatePhotofloGraph failed\n" ); reps = 0; } else { XieFloImportPhotomap(&flograph[0], XIEPhotomap, False); XieFloExportDrawable(&flograph[1], 1, /* source phototag number */ xp->w, xp->fggc, 0, 0 ); flo = XieCreatePhotoflo( xp->d, flograph, flo_elements ) ; } } if ( !reps ) { FreePhotofloDoneEventStuff( xp, p ); } return( reps ); }
PRBool DrawScaledImageXIE(Display *display, Drawable aDest, GC aGC, Drawable aSrc, PRInt32 aSrcWidth, PRInt32 aSrcHeight, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) { #ifdef DEBUG_XIE printf("DrawScaledImageXIE\n"); #endif if (!useXIE) { #ifdef DEBUG_XIE fprintf(stderr, "useXIE is false.\n"); #endif return PR_FALSE; } if (!inited) { XieExtensionInfo *info; if (useXIE) { char *text = PR_GetEnv("MOZ_DISABLE_XIE"); if (text) { #ifdef DEBUG_XIE fprintf(stderr, "MOZ_DISABLE_XIE set, disabling use of XIE.\n"); #endif useXIE = PR_FALSE; return PR_FALSE; } } if (!XieInitialize(display, &info)) { useXIE = PR_FALSE; return PR_FALSE; } inited = PR_TRUE; /* create the photospace (we only need to do this once) */ gPhotospace = XieCreatePhotospace(display); photoElement = XieAllocatePhotofloGraph(3); /* XXX we want to destroy this at shutdown XieDestroyPhotospace(display, photospace); */ } /* run the flo on the image to get a the scaled image */ DoFlo(display, aDest, aGC, aSrc, aSrcWidth, aSrcHeight, aSX, aSY, aSWidth, aSHeight, aDX, aDY, aDWidth, aDHeight); return PR_TRUE; }
int InitExportAvailableEvent(XParms xp, Parms p, int reps) { int lutSize; char *lut; XieLTriplet start, length; XIELut = ( XieLut ) NULL; flograph = ( XiePhotoElement * ) NULL; flo = ( XiePhotoflo ) NULL; lutSize = 10; lut = (char *)malloc( lutSize ); data = (char *)malloc( lutSize ); if ( lut == ( char * ) NULL || data == ( char * ) NULL ) { reps = 0; } else { if ( ( XIELut = GetXIELut( xp, p, (unsigned char *)lut, lutSize, lutSize ) ) == ( XieLut ) NULL ) { reps = 0; } else { flo_elements = 2; flograph = XieAllocatePhotofloGraph( flo_elements ); if ( flograph == ( XiePhotoElement * ) NULL ) { fprintf( stderr, "XieAllocatePhotofloGraph failed\n" ); reps = 0; } else { length[ 0 ] = lutSize; length[ 1 ] = 0; length[ 2 ] = 0; start[ 0 ] = 0; start[ 1 ] = 0; start[ 2 ] = 0; XieFloImportLUT(&flograph[0], XIELut); XieFloExportClientLUT(&flograph[1], 1, /* source phototag number */ xieValMSFirst, xieValNewData, start, length ); flo = XieCreatePhotoflo( xp->d, flograph, flo_elements ); } } } if ( lut ) free( lut ); if ( !reps ) FreeExportAvailableEventStuff( xp, p ); return( reps ); }
int InitDecodeNotifyEvent(XParms xp, Parms p, int reps) { XIEimage *image; XieDecodeUncompressedSingleParam *decode_params=NULL; XieEncodeTechnique encode_tech=xieValEncodeServerChoice; char *encode_params=NULL; XieLTriplet width, height, levels; XIEPhotomap = ( XiePhotomap ) NULL; XIEPhotomap2 = ( XiePhotomap ) NULL; flograph = ( XiePhotoElement * ) NULL; flo = ( XiePhotoflo ) NULL; image = p->finfo.image1; if ( !GetImageData( xp, p, 1 ) ) reps = 0; else { if ( !image ) reps = 0; else { size = image->fsize; width[ 0 ] = image->width[ 0 ]; height[ 0 ] = image->height[ 0 ]; levels[ 0 ] = image->levels[ 0 ]; } } if ( reps ) { XIEPhotomap = XieCreatePhotomap(xp->d); XIEPhotomap2 = XieCreatePhotomap(xp->d); decode_params = XieTecDecodeUncompressedSingle( image->fill_order, image->pixel_order, image->pixel_stride[ 0 ], image->left_pad[ 0 ], image->scanline_pad[ 0 ] ); flo_elements = 2; flograph = XieAllocatePhotofloGraph(flo_elements); if ( flograph == ( XiePhotoElement * ) NULL ) { reps = 0; } } if ( reps ) { XieFloImportClientPhoto(&flograph[0], image->bandclass, width, height, levels, True, image->decode, (char *)decode_params ); XieFloExportPhotomap(&flograph[1], 1, /* source phototag number */ XIEPhotomap2, encode_tech, encode_params ); flo = XieCreatePhotoflo( xp->d, flograph, flo_elements ); } if ( !reps ) FreeDecodeNotifyEventStuff( xp, p ); if ( decode_params ) XFree( decode_params ); return reps; }
int InitExportClientHistogram(XParms xp, Parms p, int reps) { XieProcessDomain domain; int idx, src; XieRectangle rect; ExportClParms *parms; XIEimage *image; int constrainflag = 0; parms = ( ExportClParms * )p->ts; XIELut = ( XieLut ) NULL; XIERoi = ( XieRoi ) NULL; XIEPhotomap = ( XiePhotomap ) NULL; ControlPlane = ( XiePhotomap ) NULL; histos = ( XieHistogramData * ) NULL; flograph = ( XiePhotoElement * ) NULL; flo = ( XiePhotoflo ) NULL; if ( parms ) useDomain = parms->useDomain; else useDomain = DomainNone; flo_elements = 3; image = p->finfo.image1; if ( !image ) { reps = 0; } if ( reps && ( xp->screenDepth != image->depth[ 0 ] ) ) { flo_elements+=2; constrainflag = 1; if ( ( XIELut = CreatePointLut( xp, p, 1 << image->depth[ 0 ], 1 << xp->screenDepth, False ) ) == ( XieLut ) NULL ) { reps = 0; } } if ( reps && useDomain == DomainROI ) { rect.x = parms->x; rect.y = parms->y; rect.width = parms->width; rect.height = parms->height; if ( ( XIERoi = GetXIERoi( xp, p, &rect, 1 ) ) == ( XieRoi ) NULL ) { reps = 0; } flo_elements+=1; } else if ( reps && useDomain == DomainCtlPlane ) { ControlPlane = GetControlPlane( xp, 2 ); if ( ControlPlane == ( XiePhotomap ) NULL ) reps = 0; flo_elements+=1; } if ( reps ) { histos = ( XieHistogramData * ) malloc( sizeof( XieHistogramData ) * ( 1 << image->depth[ 0 ] ) ); if ( histos == ( XieHistogramData * ) NULL ) { reps = 0; } } if ( reps ) { flograph = XieAllocatePhotofloGraph(flo_elements); if ( flograph == ( XiePhotoElement * ) NULL ) { fprintf( stderr, "XieAllocatePhotofloGraph failed\n" ); reps = 0; } else if ( ( XIEPhotomap = GetXIEPhotomap( xp, p, 1 ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { domain.offset_x = 0; domain.offset_y = 0; domain.phototag = 0; idx = 0; if ( useDomain == DomainROI ) { XieFloImportROI(&flograph[idx], XIERoi); idx++; domain.phototag = idx; } else if ( useDomain == DomainCtlPlane ) { XieFloImportPhotomap(&flograph[idx], ControlPlane, False); idx++; domain.phototag = idx; } XieFloImportPhotomap(&flograph[idx], XIEPhotomap, False ); idx++; src = idx; XieFloExportClientHistogram(&flograph[idx], idx, /* source phototag number */ &domain, xieValNewData ); idx++; histoSrc = idx; if ( constrainflag ) { XieFloImportLUT(&flograph[idx], XIELut ); idx++; domain.phototag = 0; domain.offset_x = 0; domain.offset_y = 0; XieFloPoint(&flograph[idx], src, &domain, idx, 0x7 ); idx++; src = idx; } XieFloExportDrawable(&flograph[idx], src, /* source phototag number */ xp->w, xp->fggc, 0, /* x offset in window */ 0 /* y offset in window */ ); idx++; flo = XieCreatePhotoflo( xp->d, flograph, flo_elements ); flo_notify = True; } } if ( reps ) { XMapRaised( xp->d, monitorWindow ); XSync( xp->d, 0 ); } else { FreeExportClientHistogramStuff( xp, p ); } return( reps ); }
int InitExportClientROI(XParms xp, Parms p, int reps) { int i; XIERoi = ( XieRoi ) NULL; flograph = ( XiePhotoElement * ) NULL; flo = ( XiePhotoflo ) NULL; rectsSize = (( ExportClParms * ) p->ts)->numROIs; rects = (XieRectangle *)malloc( rectsSize * sizeof( XieRectangle ) ); data = (char *) NULL; if ( rects == ( XieRectangle * ) NULL ) { reps = 0; } else { for ( i = 0; i < rectsSize; i++ ) { rects[ i ].x = i * 10; rects[ i ].y = i * 10; rects[ i ].width = i * 10; rects[ i ].height = i * 10; XFillRectangle( xp->d, xp->w, xp->fggc, rects[ i ].x, rects[ i ].y, rects[ i ].width, rects[ i ].height ); } if ( ( XIERoi = GetXIERoi( xp, p, rects, rectsSize ) ) == ( XieRoi ) NULL ) { reps = 0; } else { flo_elements = 2; flograph = XieAllocatePhotofloGraph( flo_elements ); if ( flograph == ( XiePhotoElement * ) NULL ) { fprintf( stderr, "XieAllocatePhotofloGraph failed\n" ); reps = 0; } else { XieFloImportROI(&flograph[0], XIERoi); XieFloExportClientROI(&flograph[1], 1, /* source phototag number */ xieValNewData ); flo = XieCreatePhotoflo( xp->d, flograph, flo_elements ); flo_notify = True; } } } if ( !reps ) { FreeExportClientROIStuff( xp, p ); } else dontClear = True; return( reps ); }
int InitExportClientLUT(XParms xp, Parms p, int reps) { int i; XieOrientation band_order = xieValLSFirst; XieLTriplet start, length; XIELut = ( XieLut ) NULL; flograph = ( XiePhotoElement * ) NULL; flo = ( XiePhotoflo ) NULL; histos = ( XieHistogramData * ) malloc( sizeof( XieHistogramData ) * xp->vinfo.colormap_size ); lutSize = ( xp->vinfo.colormap_size ) * sizeof( unsigned char ); lut = (unsigned char *) malloc( lutSize ); data = (char *) malloc( lutSize ); if ( lut == ( unsigned char * ) NULL || data == ( char * ) NULL || histos == ( XieHistogramData * ) NULL ) { reps = 0; } else { for ( i = 0; i < lutSize; i++ ) { lut[ i ] = ( xp->vinfo.colormap_size ) - i - 1; } if ( ( XIELut = GetXIELut( xp, p, lut, lutSize, lutSize ) ) == ( XieLut ) NULL ) { reps = 0; } } if ( reps ) { flo_elements = 2; flograph = XieAllocatePhotofloGraph( flo_elements ); if ( flograph == ( XiePhotoElement * ) NULL ) { fprintf( stderr, "XieAllocatePhotofloGraph failed\n" ); reps = 0; } } if ( reps ) { XieFloImportLUT(&flograph[0], XIELut); length[ 0 ] = xp->vinfo.colormap_size; length[ 1 ] = 0; length[ 2 ] = 0; start[ 0 ] = 0; start[ 1 ] = 0; start[ 2 ] = 0; XieFloExportClientLUT(&flograph[1], 1, /* source phototag number */ band_order, xieValNewData, start, length ); flo = XieCreatePhotoflo( xp->d, flograph, flo_elements ); flo_notify = True; } if ( !reps ) { FreeExportClientLUTStuff( xp, p ); } else { XMapRaised( xp->d, monitorWindow ); XSync( xp->d, 0 ); } return( reps ); }
int InitExportClientPhoto(XParms xp, Parms p, int reps) { char *encode_params=NULL; int *size; unsigned char pixel_stride[ 3 ]; unsigned char scanline_pad[ 3 ]; char buf[ 64 ]; flograph = ( XiePhotoElement * ) NULL; XIEPhotomap = ( XiePhotomap ) NULL; flo = ( XiePhotoflo ) NULL; image = p->finfo.image1; if ( !image ) return ( 0 ); sprintf( buf, "%s/%s", imagepath, image->fname ); size = &image->fsize; *size = GetFileSize( buf ); if ( *size == 0 ) return( 0 ); data = ( char * ) malloc( *size ); if ( data == ( char * ) NULL ) return( 0 ); flograph = XieAllocatePhotofloGraph(2); if ( flograph == ( XiePhotoElement * ) NULL ) { fprintf( stderr, "XieAllocatePhotofloGraph failed\n" ); reps = 0; } else { switch( image->decode ) { case xieValDecodeJPEGBaseline: if ( ( XIEPhotomap = GetXIETriplePhotomap( xp, p, 1 ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { unsigned char h_samples[3]; unsigned char v_samples[3]; h_samples[0] = h_samples[1] = h_samples[2] = 1; v_samples[0] = v_samples[1] = v_samples[2] = 1; encode_params = ( char * ) XieTecEncodeJPEGBaseline( image->interleave, image->band_order, h_samples, v_samples, ( char * ) NULL, 0, ( char * ) NULL, 0, ( char * ) NULL, 0 ); } break; case xieValDecodeUncompressedTriple: if ( ( XIEPhotomap = GetXIETriplePhotomap( xp, p, 1 ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { pixel_stride[ 0 ] = image->pixel_stride[ 0 ]; pixel_stride[ 1 ] = image->pixel_stride[ 1 ]; pixel_stride[ 2 ] = image->pixel_stride[ 2 ]; scanline_pad[ 0 ] = image->scanline_pad[ 0 ]; scanline_pad[ 1 ] = image->scanline_pad[ 1 ]; scanline_pad[ 2 ] = image->scanline_pad[ 2 ]; encode_params = ( char * ) XieTecEncodeUncompressedTriple( image->fill_order, image->pixel_order, image->band_order, xieValBandByPixel, pixel_stride, scanline_pad ); } break; case xieValDecodeUncompressedSingle: if ( ( XIEPhotomap = GetXIEPhotomap( xp, p, 1 ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { encode_params = ( char * ) XieTecEncodeUncompressedSingle( image->fill_order, image->pixel_order, image->pixel_stride[ 0 ], image->scanline_pad[ 0 ] ); } break; case xieValDecodeG31D: if ( ( XIEPhotomap = GetXIEFAXPhotomap( xp, p, 1, False ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { encode_params = ( char * ) XieTecEncodeG31D( False, False, xieValLSFirst ); } break; case xieValDecodeG32D: if ( ( XIEPhotomap = GetXIEFAXPhotomap( xp, p, 1, False ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { encode_params = ( char * ) XieTecEncodeG32D( False, False, False, xieValLSFirst, 1 ); } break; case xieValDecodeG42D: if ( ( XIEPhotomap = GetXIEFAXPhotomap( xp, p, 1, False ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { encode_params = ( char * ) XieTecEncodeG42D( False, False, xieValLSFirst ); } break; case xieValDecodeTIFF2: if ( ( XIEPhotomap = GetXIEFAXPhotomap( xp, p, 1, False ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { encode_params = ( char * ) XieTecEncodeTIFF2( xieValLSFirst, False ); } break; case xieValDecodeTIFFPackBits: if ( ( XIEPhotomap = GetXIEFAXPhotomap( xp, p, 1, False ) ) == ( XiePhotomap ) NULL ) { reps = 0; } else { encode_params = ( char * ) XieTecEncodeTIFFPackBits( xieValLSFirst ); } break; default: reps = 0; break; } if ( reps ) { XieFloImportPhotomap(&flograph[0], XIEPhotomap, False ); XieFloExportClientPhoto(&flograph[1], 1, /* source phototag number */ xieValNewData, image->decode, encode_params ); flo = XieCreatePhotoflo( xp->d, flograph, 2 ); flo_notify = True; } } if ( encode_params ) { if ( image->decode == xieValDecodeJPEGBaseline ) XieFreeEncodeJPEGBaseline( ( XieEncodeJPEGBaselineParam * ) encode_params ); else XFree( encode_params ); } if ( !reps ) FreeExportClientPhotoStuff( xp, p ); return( reps ); }