0023414: Remove deprecated classes Xw_PixMap and WNT_PixMap
[occt.git] / src / Xw / Xw_convert_image.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 /*
19 C<
20 C***********************************************************************
21 C
22 C     FONCTION :
23 C     ----------
24 C
25 C
26 C$    HISTORIQUE DES MODIFICATIONS   :
27 C     --------------------------------
28 C       21-02-97 : GG ; G1334-PERF 
29 C                  Ameliorer les performances de traduction
30 C                  des images XWD.
31 C                  >> Rempacer XGetPixel et XputPixel par des
32 C                  directes dans le buffer image.
33 C       07-05-97 : GG ; PRO7909
34 C                  Eviter de detruire l'image convertie lorsqu'il n'y a pas
35 C                  de conversion a faire !
36 */
37
38 #define PRO7909
39  
40 #include <Xw_Extension.h>
41
42         /* ifdef then trace on */
43 #ifdef TRACE
44 #define TRACE_CONVERT_IMAGE
45 #endif
46
47 /*
48    XW_STATUS Xw_convert_image (awindow,aimage,acolors,ncolors):
49    XW_EXT_WINDOW *awindow
50    XW_EXT_IMAGEDATA   *aimage
51    XW_EXT_COLOR *acolors        (can be NULL)
52    int ncolors
53
54         Convert an image depending of the window class
55
56         returns  ERROR if image can't be converted.
57         returns  SUCCESS if successfull
58
59 */
60
61 #define CREATE_IMAGE(_fun,_out,_nbp) \
62                                 /* Allocate the new pixel buffer */     \
63         if( !(_out = (unsigned char*) Xw_calloc(piimage->width * piimage->height,_nbp)) ) {\
64           /*ERROR*Bad Image allocation*/        \
65           Xw_set_error(60,_fun,0) ;     \
66           return NULL ; \
67         }       \
68                                 /* Create the new Image structure */    \
69         if( !(poimage = XCreateImage(_DISPLAY,_VISUAL,_DEPTH,ZPixmap,\
70                 0,(char*)_out,piimage->width,piimage->height,_nbp*8,0)) ) {\
71           /* ERROR*XImage Creation failed */    \
72           Xw_set_error(62,_fun,0) ;     \
73           Xw_free((char*)_out) ;        \
74           return NULL ; \
75         }
76
77 #define COPY_PSEUDO_TO_PSEUDO(_fun,_in,_out) \
78         for( y=0 ; y<piimage->height ; y++ ) {  \
79           for( x=0 ; x<piimage->width ; x++ ) { \
80             ipixel = *_in++;    \
81             if( ipixel != lipixel ) {   \
82               lipixel = ipixel; \
83               if( ipixel >= MAXCOLOR ) ipixel = 0 ;     \
84               opixel = mapping[ipixel] ;        \
85               if( !opixel ) {   \
86                 for( i=0,j=ipixel ; i<ncolors ; i++,j++) {      \
87                   if( j >= ncolors ) j = 0 ;    \
88                   if( ipixel == pcolors[j].pixel ) break;       \
89                 }       \
90                 red = (float)pcolors[j].red/0xFFFF ;    \
91                 green = (float)pcolors[j].green/0xFFFF ;        \
92                 blue = (float)pcolors[j].blue/0xFFFF ;  \
93                 if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
94                   /*ERROR*XImage Creation failed*/      \
95                   Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ;\
96                 }       \
97                 mapping[ipixel] = opixel ;      \
98               } \
99             }   \
100             *_out++ = opixel;   \
101           }     \
102           if( ipad > 0 ) pidata.cdata += ipad;  \
103         }       
104
105 #define COPY_PSEUDO_TO_TRUE(_fun,_in,_out) \
106         for( y=0 ; y<piimage->height ; y++ ) {  \
107           for( x=0 ; x<piimage->width ; x++ ) { \
108             ipixel = *_in++;    \
109             if( ipixel != lipixel ) {   \
110               lipixel = ipixel; \
111               if( ipixel >= MAXCOLOR ) ipixel = 0 ;     \
112               opixel = mapping[ipixel] ;        \
113               if( !opixel ) {   \
114                 for( i=0,j=ipixel ; i<ncolors ; i++,j++) {      \
115                   if( j >= ncolors ) j = 0 ;    \
116                   if( ipixel == pcolors[j].pixel ) break;       \
117                 }       \
118                 red = (float)pcolors[j].red/0xFFFF ;    \
119                 green = (float)pcolors[j].green/0xFFFF ;        \
120                 blue = (float)pcolors[j].blue/0xFFFF ;  \
121                 if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
122                   /*ERROR*XImage Creation failed*/      \
123                   Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ;\
124                 }       \
125                 mapping[ipixel] = opixel ;      \
126               } \
127             }   \
128             *_out++ = opixel;   \
129           }     \
130           if( ipad > 0 ) pidata.cdata += ipad;  \
131         }       
132
133 #define COPY_TRUE_TO_PSEUDO(_fun,_in,_out) \
134         for( y=0 ; y<piimage->height ; y++ ) {  \
135           for( x=0 ; x<piimage->width ; x++ ) { \
136             ipixel = *_in++;    \
137             if( ipixel != lipixel ) {   \
138               lipixel = ipixel; \
139               red = (float)((ipixel >> sred) & cmask)/(float)cmask;     \
140               green = (float)((ipixel >> sgreen) & cmask)/(float)cmask; \
141               blue = (float)((ipixel >> sblue) & cmask)/(float)cmask;   \
142               if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
143                 /*ERROR*XImage Creation failed*/        \
144                 Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ;       \
145               } \
146             }   \
147             *_out++ = opixel;   \
148           }     \
149           if( ipad > 0 ) pidata.cdata += ipad;  \
150         }       
151
152 #define COPY_TRUE_TO_TRUE(_fun,_in,_out) \
153         for( y=0 ; y<piimage->height ; y++ ) {  \
154           for( x=0 ; x<piimage->width ; x++ ) { \
155             ipixel = *_in++;    \
156             if( ipixel != lipixel ) {   \
157               lipixel = ipixel; \
158               red = (float)((ipixel >> sred) & cmask)/(float)cmask;     \
159               green = (float)((ipixel >> sgreen) & cmask)/(float)cmask; \
160               blue = (float)((ipixel >> sblue) & cmask)/(float)cmask;   \
161               if( !Xw_get_color_pixel(_COLORMAP,red,green,blue,&opixel,&isapproximate)) {\
162                 /*ERROR*XImage Creation failed*/        \
163                 Xw_set_error(63,_fun,&_COLORMAP->info.colormap) ;       \
164               } \
165             }   \
166             *_out++ = opixel;   \
167           }     \
168           if( ipad > 0 ) pidata.cdata += ipad;  \
169         }       
170
171
172 #ifdef XW_PROTOTYPE
173 static XImage* ConvertPseudoToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors) ;
174 static XImage* ConvertPseudoToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors) ;
175 static XImage* ConvertTrueToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage) ;
176 static XImage* ConvertTrueToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage) ;
177 #else
178 static XImage* ConvertPseudoToPseudo() ;
179 static XImage* ConvertPseudoToTrue() ;
180 static XImage* ConvertTrueToPseudo() ;
181 static XImage* ConvertTrueToTrue() ;
182 #endif /*XW_PROTOTYPE*/
183
184 #ifdef XW_PROTOTYPE
185 XW_STATUS Xw_convert_image (void *awindow,void *aimage,void *acolors,int ncolors)
186 #else
187 XW_STATUS Xw_convert_image (awindow,aimage,acolors,ncolors)
188 void *awindow;
189 void *aimage;
190 void *acolors;
191 int ncolors;
192 #endif /*XW_PROTOTYPE*/
193 {
194 XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
195 XW_EXT_IMAGEDATA *pimage = (XW_EXT_IMAGEDATA*)aimage;
196 XColor *pcolors = (XColor*)acolors;
197 XImage *piimage,*poimage = NULL;
198 XW_STATUS status = XW_ERROR;
199 int i,iclass = 0;
200
201     if( !Xw_isdefine_window(pwindow) ) {
202         /*ERROR*Bad EXT_WINDOW Address*/
203         Xw_set_error(24,"Xw_convert_image",pwindow) ;
204         return (XW_ERROR) ;
205     }
206
207     if( !Xw_isdefine_image(pimage) ) {
208          /*ERROR*Bad EXT_IMAGEDATA Address*/
209          Xw_set_error(25,"Xw_convert_image",pimage) ;
210          return (XW_ERROR) ;
211     }
212
213     piimage = (_ZIMAGE) ? _ZIMAGE : _IIMAGE;
214
215     if( !pcolors && piimage->red_mask && 
216                 piimage->green_mask && piimage->blue_mask ) iclass = TrueColor;
217     else iclass = PseudoColor;
218
219     switch ( iclass ) {
220       case PseudoColor :
221
222         if( !pcolors ) {
223           if( !_ICOLORMAP ) _ICOLORMAP = _COLORMAP;
224           ncolors = min(_IVISUAL->map_entries,MAXCOLOR);
225           pcolors = (XColor*) Xw_calloc(sizeof(XColor),ncolors);
226           for( i=0 ; i<ncolors ; i++ ) pcolors[i].pixel = i;
227           XQueryColors(_DISPLAY,_ICOLORMAP->info.colormap,pcolors,ncolors) ;
228         }
229
230         if( pcolors ) switch (_CLASS ) {
231          case PseudoColor :     /* Convert Pseudo to PseudoColor */
232            if( acolors || (_ICOLORMAP != _COLORMAP) ) {
233              poimage = ConvertPseudoToPseudo(pwindow,piimage,pcolors,ncolors) ;
234            } else {
235              poimage = piimage;
236            }
237            break ;
238          case TrueColor :       /* Convert Pseudo to TrueColor */
239            poimage = ConvertPseudoToTrue(pwindow,piimage,pcolors,ncolors) ;
240            break ;
241          default:
242            /*ERROR*Unimplemented Visual class*/
243            Xw_set_error(5,"Xw_convert_image",&_CLASS) ;
244         }
245 #ifdef BUG      /* Cette memoire est liberee par Xw_load_image !! */
246         if( pcolors && !acolors ) Xw_free(pcolors);
247 #endif
248         break ;
249
250       case TrueColor :
251         switch (_CLASS ) {
252          case PseudoColor :     /* Convert True to PseudoColor */
253            poimage = ConvertTrueToPseudo(pwindow,piimage) ;
254            break ;
255          case TrueColor :       /* Convert True to TrueColor */
256            poimage = ConvertTrueToTrue(pwindow,piimage) ;
257            break ;
258          default:
259            /*ERROR*Unimplemented Visual class*/
260            Xw_set_error(5,"Xw_convert_image",&_CLASS) ;
261         }
262         break ;
263
264         default:
265          /*ERROR*Unimplemented Visual class*/
266          Xw_set_error(5,"Xw_convert_image",&iclass) ;
267     }
268
269     _ICOLORMAP = _COLORMAP;
270     if( poimage ) {
271       status = XW_SUCCESS;
272                                 /* Destroy the old image */
273       if( _ZIMAGE && (_ZIMAGE != _IIMAGE) ) {
274         XDestroyImage(_ZIMAGE);
275         _ZIMAGE = NULL;
276       }
277                                 /* Initialize the output image */
278 #ifdef PRO7909
279       if( _IIMAGE != poimage ) {
280         XDestroyImage(_IIMAGE);
281         _IIMAGE = poimage;
282       }
283 #else
284       XDestroyImage(_IIMAGE);
285       _IIMAGE = poimage;
286 #endif
287       pimage->zoom = 1.;
288     }
289
290 #ifdef  TRACE_CONVERT_IMAGE
291 if( Xw_get_trace() ) {
292     printf (" %d = Xw_convert_image(%lx,%lx,%lx,%d)\n",
293             status,(long ) pwindow,(long ) pimage,(long ) pcolors,ncolors);
294 }
295 #endif
296
297     return (status);
298 }
299
300 #ifdef XW_PROTOTYPE
301 static XImage* ConvertTrueToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage)
302 #else
303 static XImage* ConvertTrueToPseudo(pwindow,piimage)
304 XW_EXT_WINDOW *pwindow ;
305 XImage *piimage ;
306 #endif /*XW_PROTOTYPE*/
307 /*
308         Convert TrueColor to PseudoColor Image
309 */
310 {
311 unsigned long ipixel,opixel,cmask ;
312 unsigned long lipixel = 0xFFFFFFFF ;
313 //int i,j,ipad,isapproximate ;
314 int ipad,isapproximate ;
315 int sred,sgreen,sblue ;
316 float red,green,blue ;
317 register union {
318   unsigned char *cdata ;
319   unsigned short *sdata ;
320   unsigned int *idata ;
321 } pidata,podata;
322 register int x,y;
323 XImage *poimage = NULL ;
324
325 #ifdef TRACE_CONVERT_IMAGE
326         if( Xw_get_trace() ) {
327             printf(" Xw_convert_image.TrueToPseudo()\n") ;
328         }
329 #endif
330
331     ipad =  piimage->bytes_per_line - 
332                         piimage->width * piimage->bits_per_pixel/8 ;
333     pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
334
335     sred = sgreen = sblue = 0 ;
336     cmask = piimage->red_mask ;
337     while ( !(cmask & 1) ) { cmask >>= 1 ; sred++ ; }
338     cmask = piimage->green_mask ;
339     while ( !(cmask & 1) ) { cmask >>= 1 ; sgreen++ ; }
340     cmask = piimage->blue_mask ;
341     while ( !(cmask & 1) ) { cmask >>= 1 ; sblue++ ; }
342
343     CREATE_IMAGE("ConvertTrueToPseudo",podata.cdata,1)
344     switch (piimage->bits_per_pixel) {
345       case 8 :
346          COPY_TRUE_TO_PSEUDO("ConvertTrueToPseudo",pidata.cdata,podata.cdata);
347          break;
348       case 16 :
349         COPY_TRUE_TO_PSEUDO("ConvertTrueToPseudo",pidata.sdata,podata.cdata);
350         break;
351       case 32 :
352         COPY_TRUE_TO_PSEUDO("ConvertTrueToPseudo",pidata.idata,podata.cdata);
353         break;
354       default:
355         /*ERROR*Unimplemented Image Visual depth*/
356         Xw_set_error(64,"ConvertTrueToPseudo",&piimage->bits_per_pixel);
357     }
358
359     return (poimage) ;
360 }
361
362 #ifdef XW_PROTOTYPE
363 static XImage* ConvertPseudoToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors)
364 #else
365 static XImage* ConvertPseudoToTrue(pwindow,piimage,pcolors,ncolors)
366 XW_EXT_WINDOW *pwindow ;
367 XImage *piimage ;
368 XColor *pcolors;
369 int ncolors;
370 #endif /*XW_PROTOTYPE*/
371 /*
372         Convert PseudoColor to TrueColor Image
373 */
374 {
375 unsigned long ipixel,opixel ;
376 unsigned long lipixel = 0xFFFFFFFF ;
377 unsigned long mapping[MAXCOLOR];
378 int i,j,ipad,isapproximate ;
379 float red,green,blue ;
380 register union {
381   unsigned char *cdata ;
382   unsigned short *sdata ;
383   unsigned int *idata ;
384 } pidata,podata;
385 register int x,y;
386 XImage *poimage = NULL ;
387
388 #ifdef TRACE_CONVERT_IMAGE
389         if( Xw_get_trace() ) {
390             printf(" Xw_convert_image.PseudoToTrue()\n") ;
391         }
392 #endif
393
394     for( i=0 ; i<MAXCOLOR ; i++ ) mapping[i] = 0;
395     ipad =  piimage->bytes_per_line - 
396                         piimage->width * piimage->bits_per_pixel/8 ;
397     pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
398
399     switch (_DEPTH) {
400       case 4 :
401       case 8 :
402         CREATE_IMAGE("ConvertPseudoToTrue",podata.cdata,1)
403         COPY_PSEUDO_TO_TRUE("ConvertPseudoToTrue",pidata.cdata,podata.cdata);
404         break;
405       case 12 :
406         CREATE_IMAGE("ConvertPseudoToTrue",podata.cdata,2)
407         COPY_PSEUDO_TO_TRUE("ConvertPseudoToTrue",pidata.cdata,podata.sdata);
408         break;
409       case 24 :
410         CREATE_IMAGE("ConvertPseudoToTrue",podata.cdata,4)
411         COPY_PSEUDO_TO_TRUE("ConvertPseudoToTrue",pidata.cdata,podata.idata);
412         break;
413       default:
414         /*ERROR*Unimplemented Image Visual depth*/
415         Xw_set_error(64,"ConvertPseudoToTrue",&_DEPTH);
416     }
417
418
419     return (poimage) ;
420 }
421
422 #ifdef XW_PROTOTYPE
423 static XImage* ConvertPseudoToPseudo(XW_EXT_WINDOW *pwindow,XImage *piimage,XColor *pcolors,int ncolors)
424 #else
425 static XImage* ConvertPseudoToPseudo(pwindow,piimage,pcolors,ncolors)
426 XW_EXT_WINDOW *pwindow ;
427 XImage *piimage ;
428 XColor *pcolors;
429 int ncolors;
430 #endif /*XW_PROTOTYPE*/
431 /*
432         Convert PseudoColor to PseudoColor Image
433 */
434 {
435 unsigned long ipixel,opixel ;
436 unsigned long lipixel = 0xFFFFFFFF ;
437 unsigned long mapping[MAXCOLOR];
438 int i,j,ipad,isapproximate ;
439 float red,green,blue ;
440 register union {
441   unsigned char *cdata ;
442   unsigned short *sdata ;
443   unsigned int *idata ;
444 } pidata,podata;
445 register int x,y;
446 XImage *poimage = NULL ;
447
448 #ifdef TRACE_CONVERT_IMAGE
449         if( Xw_get_trace() ) {
450             printf(" Xw_convert_image.PseudoToPseudo()\n") ;
451         }
452 #endif
453
454     for( i=0 ; i<MAXCOLOR ; i++ ) mapping[i] = 0;
455     ipad =  piimage->bytes_per_line - 
456                         piimage->width * piimage->bits_per_pixel/8 ;
457     pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
458
459     switch (_DEPTH) {
460       case 4 :
461       case 8 :
462         CREATE_IMAGE("ConvertPseudoToPseudo",podata.cdata,1)
463         COPY_PSEUDO_TO_PSEUDO("ConvertPseudoToPseudo",pidata.cdata,podata.cdata);
464         break;
465       default:
466         /*ERROR*Unimplemented Image Visual depth*/
467         Xw_set_error(64,"ConvertPseudoToPseudo",&_DEPTH);
468     }
469
470
471     return (poimage) ;
472 }
473
474 #ifdef XW_PROTOTYPE
475 static XImage* ConvertTrueToTrue(XW_EXT_WINDOW *pwindow,XImage *piimage)
476 #else
477 static XImage* ConvertTrueToTrue(pwindow,piimage)
478 XW_EXT_WINDOW *pwindow ;
479 XImage *piimage ;
480 #endif /*XW_PROTOTYPE*/
481 /*
482         Convert TrueColor to TrueColor Image
483 */
484 {
485 unsigned long ipixel,opixel,cmask ;
486 unsigned long lipixel = 0xFFFFFFFF ;
487 //int i,j,ipad,isapproximate ;
488 int ipad,isapproximate ;
489 int sred,sgreen,sblue ;
490 float red,green,blue ;
491 register union {
492   unsigned char *cdata ;
493   unsigned short *sdata ;
494   unsigned int *idata ;
495 } pidata,podata;
496 register int x,y;
497 XImage *poimage = NULL ;
498
499 #ifdef TRACE_CONVERT_IMAGE
500         if( Xw_get_trace() ) {
501             printf(" Xw_convert_image.TrueToTrue()\n") ;
502         }
503 #endif
504
505     if( (_DEPTH == piimage->depth) &&
506           (_VISUAL->red_mask == piimage->red_mask) &&
507             (_VISUAL->green_mask == piimage->green_mask) &&
508               (_VISUAL->blue_mask == piimage->blue_mask) ) return piimage;
509
510     ipad =  piimage->bytes_per_line - 
511                         piimage->width * piimage->bits_per_pixel/8 ;
512     pidata.cdata = (unsigned char*)piimage->data + piimage->xoffset;
513
514     sred = sgreen = sblue = 0 ;
515     cmask = piimage->red_mask ;
516     while ( !(cmask & 1) ) { cmask >>= 1 ; sred++ ; }
517     cmask = piimage->green_mask ;
518     while ( !(cmask & 1) ) { cmask >>= 1 ; sgreen++ ; }
519     cmask = piimage->blue_mask ;
520     while ( !(cmask & 1) ) { cmask >>= 1 ; sblue++ ; }
521
522     switch (_DEPTH) {
523       case 4 :
524       case 8 :
525         CREATE_IMAGE("ConvertTrueToTrue",podata.cdata,1)
526         switch (piimage->bits_per_pixel) {
527           case 8 :      
528             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.cdata,podata.cdata);
529             break;
530           case 16 :
531             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.sdata,podata.cdata);
532             break;
533           case 32 :
534             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.idata,podata.cdata);
535             break;
536           default:
537             /*ERROR*Unimplemented Image Visual depth*/
538             Xw_set_error(64,"ConvertTrueToTrue",&piimage->bits_per_pixel);
539         }
540         break;
541       case 12 :
542         CREATE_IMAGE("ConvertTrueToTrue",podata.cdata,2)
543         switch (piimage->bits_per_pixel) {
544           case 8 :      
545             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.cdata,podata.sdata);
546             break;
547           case 16 :
548             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.sdata,podata.sdata);
549             break;
550           case 32 :
551             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.idata,podata.sdata);
552             break;
553           default:
554             /*ERROR*Unimplemented Image Visual depth*/
555             Xw_set_error(64,"ConvertTrueToTrue",&piimage->bits_per_pixel);
556         }
557         break;
558       case 24 :
559         CREATE_IMAGE("ConvertTrueToTrue",podata.cdata,4)
560         switch (piimage->bits_per_pixel) {
561           case 8 :      
562             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.cdata,podata.idata);
563             break;
564           case 16 :
565             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.sdata,podata.idata);
566             break;
567           case 32 :
568             COPY_TRUE_TO_TRUE("ConvertTrueToTrue",pidata.idata,podata.idata);
569             break;
570           default:
571             /*ERROR*Unimplemented Image Visual depth*/
572             Xw_set_error(64,"ConvertTrueToTrue",&piimage->bits_per_pixel);
573         }
574         break;
575       default:
576         /*ERROR*Unimplemented Image Visual depth*/
577         Xw_set_error(64,"ConvertTrueToTrue",&_DEPTH);
578     }
579
580     return (poimage) ;
581 }