00001 #ifndef LIBAFTERIMAGE_XIMAGE_HEADER_FILE_INCLUDED 00002 #define LIBAFTERIMAGE_XIMAGE_HEADER_FILE_INCLUDED 00003 00004 #include "asvisual.h" 00005 #include "blender.h" 00006 #include "asimage.h" 00007 00008 #ifdef __cplusplus 00009 extern "C" { 00010 #endif 00011 00012 /****h* libAfterImage/ximage.h 00013 * NAME 00014 * ximage - Defines conversion to and from XImages and Pixmaps. 00015 * DESCRIPTION 00016 * ximage2asimage() - convert XImage structure into ASImage 00017 * pixmap2asimage() - convert X11 pixmap into ASImage 00018 * asimage2ximage() - convert ASImage into XImage 00019 * asimage2mask_ximage() - convert alpha channel of ASImage into XImage 00020 * asimage2pixmap() - convert ASImage into Pixmap ( possibly using 00021 * precreated XImage ) 00022 * asimage2mask() - convert alpha channel of ASImage into 1 bit 00023 * mask Pixmap. 00024 * SEE ALSO 00025 * Other libAfterImage modules : 00026 * ascmap.h asfont.h asimage.h asvisual.h blender.h export.h 00027 * import.h transform.h ximage.h 00028 * AUTHOR 00029 * Sasha Vasko <sasha at aftercode dot net> 00030 *******/ 00031 00032 /****f* libAfterImage/picture_ximage2asimage() 00033 * NAME 00034 * picture_ximage2asimage() 00035 * SYNOPSIS 00036 * ASImage *picture_ximage2asimage ( struct ASVisual *asv, 00037 * XImage * xim, XImage *alpha_xim, 00038 * unsigned int compression ); 00039 * INPUTS 00040 * asv - pointer to valid ASVisual structure 00041 * xim - source XImage 00042 * alpha_xim - source XImage for Alpha channel 00043 * compression - degree of compression of resulting ASImage. 00044 * RETURN VALUE 00045 * pointer to newly allocated ASImage, containing encoded data, on 00046 * success. NULL on failure. 00047 * DESCRIPTION 00048 * picture_ximage2asimage will attempt to create new ASImage with the same 00049 * dimensions as supplied XImage. If both XImages are supplied - they must 00050 * have same dimentions. XImage will be decoded based on 00051 * supplied ASVisual, and resulting scanlines will be encoded into 00052 * ASImage. 00053 *********/ 00054 /****f* libAfterImage/ximage2asimage() 00055 * NAME 00056 * ximage2asimage() - same as picture_ximage2asimage with alpha_ximage 00057 * set to NULL. Supplied for compatibility with older versions and for 00058 * convinience. 00059 * SYNOPSIS 00060 * ASImage *ximage2asimage ( struct ASVisual *asv, XImage * xim, 00061 * unsigned int compression ); 00062 * INPUTS 00063 * asv - pointer to valid ASVisual structure 00064 * xim - source XImage 00065 * compression - degree of compression of resulting ASImage. 00066 * RETURN VALUE 00067 * pointer to newly allocated ASImage, containing encoded data, on 00068 * success. NULL on failure. 00069 * DESCRIPTION 00070 *********/ 00071 /****f* libAfterImage/pixmap2asimage() 00072 * NAME 00073 * pixmap2asimage() 00074 * SYNOPSIS 00075 * ASImage *pixmap2ximage( ASVisual *asv, Pixmap p, int x, int y, 00076 * unsigned int width, unsigned int height, 00077 * unsigned long plane_mask, 00078 * unsigned int compression); 00079 * INPUTS 00080 * asv - pointer to valid ASVisual structure 00081 * p - source Pixmap 00082 * x, y, 00083 * width, height- rectangle on Pixmap to be encoded into ASImage. 00084 * plane_mask - limits color planes to be copied from Pixmap. 00085 * keep_cache - indicates if we should keep XImage, used to copy 00086 * image data from the X server, and attached it to 00087 * ximage member of resulting ASImage. 00088 * compression - degree of compression of resulting ASImage. 00089 * RETURN VALUE 00090 * pointer to newly allocated ASImage, containing data in XImage format, 00091 * on success. NULL on failure. 00092 * DESCRIPTION 00093 * pixmap2ximage will obtain XImage of the requested area of the 00094 * X Pixmap, and it will attach it to newly created ASImage using 00095 * alt.ximage member. After that newly created ASImage could be used 00096 * in any transformations. 00097 *********/ 00098 /****f* libAfterImage/picture2asimage() 00099 * NAME 00100 * picture2asimage() 00101 * SYNOPSIS 00102 * ASImage *picture2asimage (struct ASVisual *asv, 00103 * Pixmap rgb, Pixmap a, 00104 * int x, int y, 00105 * unsigned int width, 00106 * unsigned int height, 00107 * unsigned long plane_mask, 00108 * Bool keep_cache, 00109 * unsigned int compression ); 00110 * INPUTS 00111 * asv - pointer to valid ASVisual structure 00112 * rgb - source Pixmap for red, green and blue channels 00113 * a - source Pixmap for the alpha channel 00114 * x, y, 00115 * width, height- rectangle on Pixmap to be encoded into ASImage. 00116 * plane_mask - limits color planes to be copied from Pixmap. 00117 * keep_cache - indicates if we should keep XImage, used to copy 00118 * image data from the X server, and attached it to 00119 * ximage member of resulting ASImage. 00120 * compression - degree of compression of resulting ASImage. 00121 * RETURN VALUE 00122 * pointer to newly allocated ASImage, containing encoded data, on 00123 * success. NULL on failure. 00124 * DESCRIPTION 00125 * picture2asimage will obtain XImage of the requested area of the 00126 * X Pixmap, If alpha channel pixmap is supplied - it will be used to 00127 * encode ASImage's alpha channel. Alpha channel pixmap must be either 00128 * 8 or 1 bit deep, and it must have the same dimentions as main Pixmap. 00129 *********/ 00130 /****f* libAfterImage/pixmap2asimage() 00131 * NAME 00132 * pixmap2asimage() 00133 * SYNOPSIS 00134 * ASImage *pixmap2asimage ( struct ASVisual *asv, Pixmap p, 00135 * int x, int y, 00136 * unsigned int width, 00137 * unsigned int height, 00138 * unsigned long plane_mask, 00139 * Bool keep_cache, 00140 * unsigned int compression ); 00141 * INPUTS 00142 * asv - pointer to valid ASVisual structure 00143 * p - source Pixmap 00144 * x, y, 00145 * width, height- rectangle on Pixmap to be encoded into ASImage. 00146 * plane_mask - limits color planes to be copied from Pixmap. 00147 * keep_cache - indicates if we should keep XImage, used to copy 00148 * image data from the X server, and attached it to 00149 * ximage member of resulting ASImage. 00150 * compression - degree of compression of resulting ASImage. 00151 * RETURN VALUE 00152 * pointer to newly allocated ASImage, containing encoded data, on 00153 * success. NULL on failure. 00154 * DESCRIPTION 00155 * same as picture2asimage() with alpha pixmap set to None. Supplied for 00156 * compatibility and convinience. 00157 *********/ 00158 ASImage *picture_ximage2asimage (ASVisual *asv, XImage *xim, XImage *alpha_xim, unsigned int compression); 00159 ASImage *ximage2asimage (struct ASVisual *asv, XImage * xim, unsigned int compression); 00160 ASImage *pixmap2ximage( ASVisual *asv, Pixmap p, int x, int y, 00161 unsigned int width, unsigned int height, 00162 unsigned long plane_mask, unsigned int compression); 00163 ASImage *picture2asimage(ASVisual *asv, Pixmap rgb, Pixmap a , int x, int y, 00164 unsigned int width, unsigned int height, 00165 unsigned long plane_mask, Bool keep_cache, unsigned int compression); 00166 ASImage *pixmap2asimage (struct ASVisual *asv, Pixmap p, int x, int y, 00167 unsigned int width, unsigned int height, 00168 unsigned long plane_mask, Bool keep_cache, unsigned int compression); 00169 00170 /****f* libAfterImage/asimage2ximage() 00171 * NAME 00172 * asimage2ximage() 00173 * SYNOPSIS 00174 * XImage *asimage2ximage (struct ASVisual *asv, ASImage *im); 00175 * INPUTS 00176 * asv - pointer to valid ASVisual structure 00177 * im - source ASImage 00178 * RETURN VALUE 00179 * On success returns newly created and encoded XImage of the same 00180 * colordepth as the supplied ASVisual. NULL on failure. 00181 * DESCRIPTION 00182 * asimage2ximage() creates new XImage of the exact same size as 00183 * supplied ASImage, and depth of supplied ASVisual. REd, Green and 00184 * Blue channels of ASImage then gets decoded, and encoded into XImage. 00185 * Missing scanlines get filled with black color. 00186 * NOTES 00187 * Returned pointer to XImage will also be stored in im->alt.ximage, 00188 * and It will be destroyed when XImage is destroyed, or reused in any 00189 * subsequent calls to asimage2ximage(). If any other behaviour is 00190 * desired - make sure you set im->alt.ximage to NULL, to dissociate 00191 * XImage object from ASImage. 00192 * SEE ALSO 00193 * create_visual_ximage() 00194 *********/ 00195 /****f* libAfterImage/asimage2alpha_ximage() 00196 * NAME 00197 * asimage2alpha_ximage() 00198 * SYNOPSIS 00199 * XImage *asimage2alpha_ximage (struct ASVisual *asv, 00200 * ASImage *im, Bool bitmap); 00201 * INPUTS 00202 * asv - pointer to valid ASVisual structure 00203 * im - source ASImage 00204 * bitmap - if True resulting XImage will have depth of 1 bit - 00205 * traditional X mask; otherwise it will have depth of 8 00206 * (usefull for XFree86 RENDER extension) 00207 * RETURN VALUE 00208 * On success returns newly created and encoded XImage of the depth 1 or 8. 00209 * NULL on failure. 00210 * DESCRIPTION 00211 * asimage2alpha_ximage() creates new XImage of the exact same size as 00212 * supplied ASImage, and depth 1 or 8. Alpha channels of ASImage then gets 00213 * decoded, and encoded into XImage. In case requested depth is 1 then 00214 * alpha channel is interpreted like so: 127 or greater is encoded as 1, 00215 * otherwise as 0. 00216 * Missing scanlines get filled with 1s as they signify absence of mask. 00217 * NOTES 00218 * Returned pointer to XImage will also be stored in im->alt.mask_ximage, 00219 * and It will be destroyed when XImage is destroyed, or reused in any 00220 * subsequent calls to asimage2mask_ximage(). If any other behaviour is 00221 * desired - make sure you set im->alt.mask_ximage to NULL, to dissociate 00222 * XImage object from ASImage. 00223 *********/ 00224 /****f* libAfterImage/asimage2mask_ximage() 00225 * NAME 00226 * asimage2mask_ximage() - same as asimage2alpha_ximage(). Supplied for 00227 * convinience and compatibility with older versions. 00228 * SYNOPSIS 00229 * XImage *asimage2mask_ximage (struct ASVisual *asv, ASImage *im); 00230 * INPUTS 00231 * asv - pointer to valid ASVisual structure 00232 * im - source ASImage 00233 * RETURN VALUE 00234 * On success returns newly created and encoded XImage of the depth 1. 00235 * NULL on failure. 00236 *********/ 00237 /****f* libAfterImage/asimage2pixmap() 00238 * NAME 00239 * asimage2pixmap() 00240 * SYNOPSIS 00241 * Bool asimage2drawable( struct ASVisual *asv, Drawable d, ASImage *im, 00242 * GC gc, 00243 * int src_x, int src_y, int dest_x, int dest_y, 00244 * unsigned int width, unsigned int height, 00245 * Bool use_cached); 00246 * INPUTS 00247 * asv - pointer to valid ASVisual structure 00248 * d - destination drawable - Pixmap or Window 00249 * im - source ASImage 00250 * gc - precreated GC to use for XImage transfer. If NULL, 00251 * asimage2drawable() will use DefaultGC. 00252 * src_x - Specifies the offset in X from the left edge of the image 00253 * defined by the ASImage structure. 00254 * src_y - Specifies the offset in Y from the top edge of the image 00255 * defined by the ASImage structure. 00256 * dest_x,dest_y- Specify the x and y coordinates, which are relative to 00257 * the origin of the drawable and are the coordinates of 00258 * the subimage. 00259 * width,height - Specify the width and height of the subimage, which 00260 * define the dimensions of the rectangle. 00261 * use_cached - If True will make asimage2pixmap() to use XImage 00262 * attached to ASImage, instead of creating new one. Only 00263 * works if ASImage->ximage data member is not NULL. 00264 * RETURN VALUE 00265 * On success returns True. 00266 * DESCRIPTION 00267 * asimage2drawable() creates will copy portion of ASImage onto the X 00268 * Drawable. It checks if it needs to encode XImage 00269 * from ASImage data, and calls asimage2ximage() if yes, it has to. 00270 * It then supplied gc or DefaultGC of the screen to transfer 00271 * XImage to the server. 00272 * Missing scanlines get filled with black color. 00273 * SEE ALSO 00274 * asimage2ximage() 00275 * asimage2pixmap() 00276 * create_visual_pixmap() 00277 *********/ 00278 00279 /****f* libAfterImage/asimage2pixmap() 00280 * NAME 00281 * asimage2pixmap() 00282 * SYNOPSIS 00283 * Pixmap asimage2pixmap ( struct ASVisual *asv, Window root, 00284 * ASImage *im, GC gc, Bool use_cached); 00285 * INPUTS 00286 * asv - pointer to valid ASVisual structure 00287 * root - root window of destination screen 00288 * im - source ASImage 00289 * gc - precreated GC to use for XImage transfer. If NULL, 00290 * asimage2pixmap() will use DefaultGC. 00291 * use_cached - If True will make asimage2pixmap() to use XImage 00292 * attached to ASImage, instead of creating new one. Only 00293 * works if ASImage->ximage data member is not NULL. 00294 * RETURN VALUE 00295 * On success returns newly pixmap of the same colordepth as ASVisual. 00296 * None on failure. 00297 * DESCRIPTION 00298 * asimage2pixmap() creates new pixmap of exactly same size as 00299 * supplied ASImage. It then calls asimage2drawable to copy entire content 00300 * of the ASImage onto that created pixmap. 00301 * EXAMPLE 00302 * asview.c: ASView.5 00303 * SEE ALSO 00304 * asimage2ximage() 00305 * asimage2drawable() 00306 * create_visual_pixmap() 00307 *********/ 00308 /****f* libAfterImage/asimage2mask() 00309 * NAME 00310 * asimage2mask() 00311 * SYNOPSIS 00312 * Pixmap asimage2mask ( struct ASVisual *asv, Window root, 00313 * ASImage *im, GC gc, Bool use_cached); 00314 * asv - pointer to valid ASVisual structure 00315 * root - root window of destination screen 00316 * im - source ASImage 00317 * gc - precreated GC for 1 bit deep drawables to use for 00318 * XImage transfer. If NULL, asimage2mask() will create one. 00319 * use_cached - If True will make asimage2mask() to use mask XImage 00320 * attached to ASImage, instead of creating new one. Only 00321 * works if ASImage->alt.mask_ximage data member is not NULL. 00322 * RETURN VALUE 00323 * On success returns newly created pixmap of the colordepth 1. 00324 * None on failure. 00325 * DESCRIPTION 00326 * asimage2mask() creates new pixmap of exactly same size as 00327 * supplied ASImage. It then calls asimage2mask_ximage(). 00328 * It then uses supplied gc, or creates new gc, to transfer 00329 * XImage to the server and put it on Pixmap. 00330 * Missing scanlines get filled with 1s. 00331 * SEE ALSO 00332 * asimage2mask_ximage() 00333 **********/ 00334 XImage *asimage2ximage (struct ASVisual *asv, ASImage *im); 00335 Bool subimage2ximage (struct ASVisual *asv, ASImage *im, int x, int y, XImage* xim); 00336 Bool put_ximage( ASVisual *asv, XImage *xim, Drawable d, GC gc, 00337 int src_x, int src_y, int dest_x, int dest_y, 00338 unsigned int width, unsigned int height ); 00339 00340 00341 XImage *asimage2alpha_ximage (ASVisual *asv, ASImage *im, Bool bitmap ); 00342 XImage *asimage2mask_ximage (struct ASVisual *asv, ASImage *im); 00343 Bool asimage2drawable( struct ASVisual *asv, Drawable d, ASImage *im, GC gc, 00344 int src_x, int src_y, int dest_x, int dest_y, 00345 unsigned int width, unsigned int height, 00346 Bool use_cached); 00347 /* these will do the same, but will use OpenGL API where available */ 00348 Bool asimage2drawable_gl( ASVisual *asv, Drawable d, ASImage *im, 00349 int src_x, int src_y, int dest_x, int dest_y, 00350 int width, int height, int d_width, int d_height, 00351 Bool force_direct ); 00352 00353 Bool asimage2alpha_drawable( ASVisual *asv, Drawable d, ASImage *im, GC gc, 00354 int src_x, int src_y, int dest_x, int dest_y, 00355 unsigned int width, unsigned int height, 00356 Bool use_cached); 00357 Pixmap asimage2pixmap (struct ASVisual *asv, Window root, ASImage *im, GC gc, Bool use_cached); 00358 Pixmap asimage2alpha (struct ASVisual *asv, Window root, ASImage *im, GC gc, Bool use_cached, Bool bitmap); 00359 Pixmap asimage2mask (struct ASVisual *asv, Window root, ASImage *im, GC gc, Bool use_cached); 00360 00361 #ifdef __cplusplus 00362 } 00363 #endif 00364 00365 #endif