00001 #ifndef TRANSFORM_HEADER_FILE_INCLUDED 00002 #define TRANSFORM_HEADER_FILE_INCLUDED 00003 00004 #include "asvisual.h" 00005 #include "blender.h" 00006 #include "asimage.h" 00007 00008 00009 #ifdef __cplusplus 00010 extern "C" { 00011 #endif 00012 00013 /****h* libAfterImage/transform.h 00014 * NAME 00015 * transform 00016 * SYNOPSIS 00017 * Defines transformations that could be performed on ASImage. 00018 * DESCRIPTION 00019 * 00020 * Transformations can be performed with different degree of quality. 00021 * Internal engine uses 24.8 bits per channel per pixel. As the result 00022 * there are no precision loss, while performing complex calculations. 00023 * Error diffusion algorithms could be used to transform it back into 8 00024 * bit without quality loss. 00025 * 00026 * Any Transformation could be performed with the result written directly 00027 * into XImage, so that it could be displayed faster. 00028 * 00029 * Complex interpolation algorithms are used to perform scaling 00030 * operations, thus yielding very good quality. All the transformations 00031 * are performed in integer math, with the result of greater speeds. 00032 * Optional MMX inline assembly has been incorporated into some 00033 * procedures, and allows to achieve considerably better performance on 00034 * compatible CPUs. 00035 * 00036 * SEE ALSO 00037 * Transformations : 00038 * scale_asimage(), tile_asimage(), merge_layers(), 00039 * make_gradient(), flip_asimage(), mirror_asimage(), 00040 * pad_asimage(), blur_asimage_gauss(), fill_asimage(), 00041 * adjust_asimage_hsv() 00042 * 00043 * Other libAfterImage modules : 00044 * ascmap.h asfont.h asimage.h asvisual.h blender.h export.h 00045 * import.h transform.h ximage.h 00046 * AUTHOR 00047 * Sasha Vasko <sasha at aftercode dot net> 00048 *******/ 00049 /****f* libAfterImage/transform/scale_asimage() 00050 * NAME 00051 * scale_asimage() - scales source ASImage into new image of requested 00052 * dimensions. 00053 * SYNOPSIS 00054 * ASImage *scale_asimage( struct ASVisual *asv, 00055 * ASImage *src, 00056 * unsigned int to_width, 00057 * unsigned int to_height, 00058 * ASAltImFormats out_format, 00059 * unsigned int compression_out, int quality ); 00060 * INPUTS 00061 * asv - pointer to valid ASVisual structure 00062 * src - source ASImage 00063 * to_width - desired width of the resulting image 00064 * to_height - desired height of the resulting image 00065 * out_format - optionally describes alternative ASImage format that 00066 * should be produced as the result - XImage, ARGB32, etc. 00067 * compression_out- compression level of resulting image in range 0-100. 00068 * quality - output quality 00069 * RETURN VALUE 00070 * returns newly created and encoded ASImage on success, NULL of failure. 00071 * DESCRIPTION 00072 * If size has to be reduced - then several neighboring pixels will be 00073 * averaged into single pixel. If size has to be increased then new 00074 * pixels will be interpolated based on values of four neighboring pixels. 00075 * EXAMPLE 00076 * ASScale 00077 *********/ 00078 /****f* libAfterImage/transform/tile_asimage() 00079 * NAME 00080 * tile_asimage() - tiles/crops ASImage to desired size, while optionaly 00081 * tinting it at the same time. 00082 * SYNOPSIS 00083 * ASImage *tile_asimage ( struct ASVisual *asv, 00084 * ASImage *src, 00085 * int offset_x, 00086 * int offset_y, 00087 * unsigned int to_width, 00088 * unsigned int to_height, 00089 * ARGB32 tint, 00090 * ASAltImFormats out_format, 00091 * unsigned int compression_out, int quality ); 00092 * INPUTS 00093 * asv - pointer to valid ASVisual structure 00094 * src - source ASImage 00095 * offset_x - left clip margin 00096 * offset_y - right clip margin 00097 * to_width - desired width of the resulting image 00098 * to_height - desired height of the resulting image 00099 * tint - ARGB32 value describing tinting color. 00100 * out_format - optionally describes alternative ASImage format that 00101 * should be produced as the result - XImage, ARGB32, etc. 00102 * compression_out- compression level of resulting image in range 0-100. 00103 * quality - output quality 00104 * RETURN VALUE 00105 * returns newly created and encoded ASImage on success, NULL of failure. 00106 * DESCRIPTION 00107 * Offset_x and offset_y define origin on source image from which 00108 * tiling will start. If offset_x or offset_y is outside of the image 00109 * boundaries, then it will be reduced by whole number of image sizes to 00110 * fit inside the image. At the time of tiling image will be tinted 00111 * unless tint == 0. 00112 * EXAMPLE 00113 * ASTile 00114 *********/ 00115 /****f* libAfterImage/transform/merge_layers() 00116 * NAME 00117 * merge_layers() 00118 * SYNOPSIS 00119 * ASImage *merge_layers ( struct ASVisual *asv, 00120 * ASImageLayer *layers, int count, 00121 * unsigned int dst_width, 00122 * unsigned int dst_height, 00123 * ASAltImFormats out_format, 00124 * unsigned int compression_out, int quality); 00125 * INPUTS 00126 * asv - pointer to valid ASVisual structure 00127 * layers - array of ASImageLayer structures that will be rendered 00128 * one on top of another. First element corresponds to 00129 * the bottommost layer. 00130 * dst_width - desired width of the resulting image 00131 * dst_height - desired height of the resulting image 00132 * out_format - optionally describes alternative ASImage format that 00133 * should be produced as the result - XImage, ARGB32, etc. 00134 * compression_out - compression level of resulting image in range 0-100. 00135 * quality - output quality 00136 * RETURN VALUE 00137 * returns newly created and encoded ASImage on success, NULL of failure. 00138 * DESCRIPTION 00139 * merge_layers() will create new ASImage of requested size. It will then 00140 * go through all the layers, and fill image with composition. 00141 * Bottommost layer will be used unchanged and above layers will be 00142 * superimposed on it, using algorithm specified in ASImageLayer 00143 * structure of the overlaying layer. Layers may have smaller size 00144 * then destination image, and maybe placed in arbitrary locations. Each 00145 * layer will be padded to fit width of the destination image with all 0 00146 * effectively making it transparent. 00147 *********/ 00148 /****f* libAfterImage/transform/make_gradient() 00149 * NAME 00150 * make_gradient() - renders linear gradient into new ASImage 00151 * SYNOPSIS 00152 * ASImage *make_gradient ( struct ASVisual *asv, 00153 * struct ASGradient *grad, 00154 * unsigned int width, 00155 * unsigned int height, 00156 * ASFlagType filter, 00157 * ASAltImFormats out_format, 00158 * unsigned int compression_out, int quality); 00159 * INPUTS 00160 * asv - pointer to valid ASVisual structure 00161 * grad - ASGradient structure defining how gradient should be 00162 * drawn 00163 * width - desired width of the resulting image 00164 * height - desired height of the resulting image 00165 * filter - only channels corresponding to set bits will be 00166 * rendered. 00167 * out_format - optionally describes alternative ASImage format that 00168 * should be produced as the result - XImage, ARGB32, etc. 00169 * compression_out- compression level of resulting image in range 0-100. 00170 * quality - output quality 00171 * RETURN VALUE 00172 * returns newly created and encoded ASImage on success, NULL of failure. 00173 * DESCRIPTION 00174 * make_gradient() will create new image of requested size and it will 00175 * fill it with gradient, described in structure pointed to by grad. 00176 * Different dithering techniques will be applied to produce nicer 00177 * looking gradients. 00178 *********/ 00179 /****f* libAfterImage/transform/flip_asimage() 00180 * NAME 00181 * flip_asimage() - rotates ASImage in 90 degree increments 00182 * SYNOPSIS 00183 * ASImage *flip_asimage ( struct ASVisual *asv, 00184 * ASImage *src, 00185 * int offset_x, int offset_y, 00186 * unsigned int to_width, 00187 * unsigned int to_height, 00188 * int flip, ASAltImFormats out_format, 00189 * unsigned int compression_out, int quality ); 00190 * INPUTS 00191 * asv - pointer to valid ASVisual structure 00192 * src - source ASImage 00193 * offset_x - left clip margin 00194 * offset_y - right clip margin 00195 * to_width - desired width of the resulting image 00196 * to_height - desired height of the resulting image 00197 * flip - flip flags determining degree of rotation. 00198 * out_format - optionally describes alternative ASImage format that 00199 * should be produced as the result - XImage, ARGB32, etc. 00200 * compression_out - compression level of resulting image in range 0-100. 00201 * quality - output quality 00202 * RETURN VALUE 00203 * returns newly created and encoded ASImage on success, NULL of failure. 00204 * DESCRIPTION 00205 * flip_asimage() will create new image of requested size, it will then 00206 * tile source image based on offset_x, offset_y, and destination size, 00207 * and it will rotate it then based on flip value. Three rotation angles 00208 * supported 90, 180 and 270 degrees. 00209 *********/ 00210 /****f* libAfterImage/transform/mirror_asimage() 00211 * NAME 00212 * mirror_asimage() 00213 * SYNOPSIS 00214 * ASImage *mirror_asimage ( struct ASVisual *asv, 00215 * ASImage *src, 00216 * int offset_x, int offset_y, 00217 * unsigned int to_width, 00218 * unsigned int to_height, 00219 * Bool vertical, ASAltImFormats out_format, 00220 * unsigned int compression_out, int quality ); 00221 * INPUTS 00222 * asv - pointer to valid ASVisual structure 00223 * src - source ASImage 00224 * offset_x - left clip margin 00225 * offset_y - right clip margin 00226 * to_width - desired width of the resulting image 00227 * to_height - desired height of the resulting image 00228 * vertical - mirror in vertical direction. 00229 * out_format - optionally describes alternative ASImage format that 00230 * should be produced as the result - XImage, ARGB32, etc. 00231 * compression_out - compression level of resulting image in range 0-100. 00232 * quality - output quality 00233 * RETURN VALUE 00234 * returns newly created and encoded ASImage on success, NULL of failure. 00235 * DESCRIPTION 00236 * mirror_asimage() will create new image of requested size, it will then 00237 * tile source image based on offset_x, offset_y, and destination size, 00238 * and it will mirror it in vertical or horizontal direction. 00239 *********/ 00240 /****f* libAfterImage/transform/pad_asimage() 00241 * NAME 00242 * pad_asimage() enlarges ASImage, padding it with specified color on 00243 * each side in accordance with requested geometry. 00244 * SYNOPSIS 00245 * ASImage *pad_asimage( ASVisual *asv, ASImage *src, 00246 * int dst_x, int dst_y, 00247 * unsigned int to_width, 00248 * unsigned int to_height, 00249 * ARGB32 color, 00250 * ASAltImFormats out_format, 00251 * unsigned int compression_out, int quality ); 00252 * INPUTS 00253 * asv - pointer to valid ASVisual structure 00254 * src - source ASImage 00255 * dst_x, dst_y - placement of the source image relative to the origin of 00256 * destination image 00257 * to_width - width of the destination image 00258 * to_height - height of the destination image 00259 * color - ARGB32 color value to pad with. 00260 * out_format - optionally describes alternative ASImage format that 00261 * should be produced as the result - XImage, ARGB32, etc. 00262 * compression_out - compression level of resulting image in range 0-100. 00263 * quality - output quality 00264 * RETURN VALUE 00265 * returns newly created and encoded ASImage on success, NULL of failure. 00266 *********/ 00267 /****f* libAfterImage/transform/blur_asimage_gauss() 00268 * NAME 00269 * blur_asimage_gauss() Performs Gaussian blurr of the image 00270 * ( usefull for drop shadows and the likes ). 00271 * SYNOPSIS 00272 * ASImage* blur_asimage_gauss( ASVisual* asv, ASImage* src, 00273 * double horz, double vert, 00274 * ASAltImFormats out_format, 00275 * unsigned int compression_out, 00276 * int quality ); 00277 * INPUTS 00278 * asv - pointer to valid ASVisual structure 00279 * src - source ASImage 00280 * horz - horizontal radius of the blurr 00281 * vert - vertical radius of the blurr 00282 * out_format - optionally describes alternative ASImage format that 00283 * should be produced as the result - XImage, ARGB32, etc. 00284 * compression_out - compression level of resulting image in range 0-100. 00285 * quality - output quality 00286 * RETURN VALUE 00287 * returns newly created and encoded ASImage on success, NULL of failure. 00288 *********/ 00289 /****f* libAfterImage/transform/fill_asimage() 00290 * NAME 00291 * fill_asimage() - Fills rectangle within the existing ASImage with 00292 * specified color. 00293 * SYNOPSIS 00294 * Bool fill_asimage( ASVisual *asv, ASImage *im, 00295 * int x, int y, int width, int height, 00296 * ARGB32 color ); 00297 * INPUTS 00298 * asv - pointer to valid ASVisual structure 00299 * im - ASImage to fill with the color 00300 * x, y - left-top corner of the rectangle to fill. 00301 * width, height - size of the rectangle to fill. 00302 * color - ARGB32 color value to fill rectangle with. 00303 * RETURN VALUE 00304 * True on success, False on failure. 00305 *********/ 00306 /****f* libAfterImage/transform/adjust_asimage_hsv() 00307 * NAME 00308 * adjust_asimage_hsv() - adjusts image color properties in HSV colorspace 00309 * SYNOPSIS 00310 * ASImage *adjust_asimage_hsv( ASVisual *asv, ASImage *src, 00311 * int offset_x, int offset_y, 00312 * unsigned int to_width, 00313 * unsigned int to_height, 00314 * unsigned int affected_hue, 00315 * unsigned int affected_radius, 00316 * int hue_offset, int saturation_offset, 00317 * int value_offset, 00318 * ASAltImFormats out_format, 00319 * unsigned int compression_out, int quality); 00320 * INPUTS 00321 * asv - pointer to valid ASVisual structure 00322 * src - ASImage to adjust colors of. 00323 * offset_x, 00324 * offset_y - position on infinite surface tiled with original image, 00325 * of the left-top corner of the area to be used for new 00326 * image. 00327 * to_width, 00328 * to_height - size of the area of the original image to be used 00329 * for new image. 00330 * affected_hue - hue in degrees in range 0-360. This allows to limit 00331 * impact of color adjustment to affect only limited 00332 * range of hues. 00333 * affected_radius Sets the diapason of the range of affected hues. 00334 * hue_offset - value by which to change hues in affected range. 00335 * saturation_offset - 00336 * value by which to change saturation of the pixels in 00337 * affected hue range. 00338 * value_offset - value by which to change Value(brightness) of pixels 00339 * in affected hue range. 00340 * out_format - optionally describes alternative ASImage format that 00341 * should be produced as the result - XImage, ARGB32, etc. 00342 * compression_out- compression level of resulting image in range 0-100. 00343 * quality - output quality 00344 * RETURN VALUE 00345 * returns newly created and encoded ASImage on success, NULL of failure. 00346 * DESCRIPTION 00347 * This function will tile original image to specified size with offsets 00348 * requested, and then it will go though it and adjust hue, saturation and 00349 * value of those pixels that have specific hue, set by affected_hue/ 00350 * affected_radius parameters. When affected_radius is greater then 180 00351 * entire image will be adjusted. Note that since grayscale colors have 00352 * no hue - the will not get adjusted. Only saturation and value will be 00353 * adjusted in gray pixels. 00354 * Hue is measured as an angle on a 360 degree circle, The following is 00355 * relationship of hue values to regular color names : 00356 * red - 0 00357 * yellow - 60 00358 * green - 120 00359 * cyan - 180 00360 * blue - 240 00361 * magenta - 300 00362 * red - 360 00363 * 00364 * All the hue values in parameters will be adjusted to fall withing 00365 * 0-360 range. 00366 *********/ 00367 00368 ASImage *scale_asimage( struct ASVisual *asv, ASImage *src, 00369 int to_width, int to_height, 00370 ASAltImFormats out_format, 00371 unsigned int compression_out, int quality ); 00372 ASImage *scale_asimage2( ASVisual *asv, ASImage *src, 00373 int clip_x, int clip_y, 00374 int clip_width, int clip_height, 00375 int to_width, int to_height, 00376 ASAltImFormats out_format, unsigned int compression_out, int quality ); 00377 00378 ASImage *tile_asimage ( struct ASVisual *asv, ASImage *src, 00379 int offset_x, int offset_y, 00380 int to_width, int to_height, ARGB32 tint, 00381 ASAltImFormats out_format, 00382 unsigned int compression_out, int quality ); 00383 ASImage *merge_layers ( struct ASVisual *asv, ASImageLayer *layers, int count, 00384 int dst_width, int dst_height, 00385 ASAltImFormats out_format, 00386 unsigned int compression_out, int quality ); 00387 ASImage *make_gradient( struct ASVisual *asv, struct ASGradient *grad, 00388 int width, int height, ASFlagType filter, 00389 ASAltImFormats out_format, 00390 unsigned int compression_out, int quality ); 00391 ASImage *flip_asimage( struct ASVisual *asv, ASImage *src, 00392 int offset_x, int offset_y, 00393 int to_width, int to_height, 00394 int flip, ASAltImFormats out_format, 00395 unsigned int compression_out, int quality ); 00396 ASImage *mirror_asimage( ASVisual *asv, ASImage *src, 00397 int offset_x, int offset_y, 00398 int to_width, 00399 int to_height, 00400 Bool vertical, ASAltImFormats out_format, 00401 unsigned int compression_out, int quality ); 00402 ASImage *pad_asimage( ASVisual *asv, ASImage *src, 00403 int dst_x, int dst_y, 00404 int to_width, 00405 int to_height, 00406 ARGB32 color, 00407 ASAltImFormats out_format, 00408 unsigned int compression_out, int quality ); 00409 ASImage* blur_asimage_gauss( ASVisual* asv, ASImage* src, 00410 double horz, double vert, 00411 ASFlagType filter, 00412 ASAltImFormats out_format, 00413 unsigned int compression_out, int quality); 00414 00415 Bool fill_asimage( ASVisual *asv, ASImage *im, 00416 int x, int y, int width, int height, 00417 ARGB32 color ); 00418 00419 ASImage* adjust_asimage_hsv( ASVisual *asv, ASImage *src, 00420 int offset_x, int offset_y, 00421 int to_width, int to_height, 00422 int affected_hue, int affected_radius, 00423 int hue_offset, int saturation_offset, int value_offset, 00424 ASAltImFormats out_format, 00425 unsigned int compression_out, int quality ); 00426 00427 /****f* libAfterImage/transform/colorize_asimage_vector() 00428 * NAME 00429 * colorize_asimage_vector() creates ASImage from double precision indexed 00430 * image data - usefull for scientific visualisation. 00431 * SYNOPSIS 00432 * Bool colorize_asimage_vector( ASVisual *asv, ASImage *im, 00433 * ASVectorPalette *palette, 00434 * ASAltImFormats out_format, 00435 * int quality ); 00436 * INPUTS 00437 * asv - pointer to valid ASVisual structure 00438 * im - ASImage to update. 00439 * palette - palette to be used in conversion of double precision 00440 * values into colors. 00441 * out_format - optionally describes alternative ASImage format that 00442 * should be produced as the result - XImage, ARGB32, etc. 00443 * quality - output quality 00444 * RETURN VALUE 00445 * True on success, False on failure. 00446 * DESCRIPTION 00447 * This function will try to convert double precision indexed image data 00448 * into actuall color image using palette. Original data should be 00449 * attached to ASImage using vector member. Operation is relatively fast 00450 * and allows representation of scientific data as color image with 00451 * dynamically changing palette. 00452 *********/ 00453 /****f* libAfterImage/transform/create_asimage_from_vector() 00454 * NAME 00455 * create_asimage_from_vector() - convinience function allowing to 00456 * create new ASImage, set its vector data and colorize it using 00457 * palette - all in one step. 00458 * SYNOPSIS 00459 * ASImage *create_asimage_from_vector( ASVisual *asv, double *vector, 00460 * unsigned int width, 00461 * unsigned int height, 00462 * ASVectorPalette *palette, 00463 * ASAltImFormats out_format, 00464 * unsigned int compression, 00465 * int quality ); 00466 * INPUTS 00467 * asv - pointer to valid ASVisual structure 00468 * vector - data to be attached to new ASImage and used to generate 00469 * RGB image 00470 * width, height - size of the new image. 00471 * palette - palette to be used in conversion of double precision 00472 * values into colors. 00473 * out_format - optionally describes alternative ASImage format that 00474 * should be produced as the result - XImage, ARGB32, etc. 00475 * compression_out- compression level of resulting image in range 0-100. 00476 * quality - output quality 00477 * RETURN VALUE 00478 * New ASImage on success, NULL on failure. 00479 * SEE ALSO 00480 * colorize_asimage_vector(), create_asimage(), set_asimage_vector() 00481 *********/ 00482 /****f* libAfterImage/transform/slice_asimage2() 00483 * NAME 00484 * slice_asimage2() - slice ASImage leaving its corners intact, and scaling 00485 * the middle part. 00486 * SYNOPSIS 00487 * ASImage* 00488 * slice_asimage2( ASVisual *asv, ASImage *src, 00489 * int slice_x_start, int slice_x_end, 00490 * int slice_y_start, int slice_y_end, 00491 * int to_width, 00492 * int to_height, 00493 * Bool scaled, 00494 * ASAltImFormats out_format, 00495 * unsigned int compression_out, int quality ); 00496 * INPUTS 00497 * asv - pointer to valid ASVisual structure 00498 * src - source ASImage. 00499 * slice_x_start - ending of the left corners 00500 * slice_x_end - begining of the right corners 00501 * slice_y_start - ending of the top corners 00502 * slice_y_end - begining of the bottom corners 00503 * to_width - width of the generated image; 00504 * to_height - height of the generated image; 00505 * scaled - if True - middle part of the image will be scaled, 00506 * otherwise - tiled; 00507 * out_format - optionally describes alternative ASImage format that 00508 * should be produced as the result - XImage, ARGB32, etc.; 00509 * compression_out- compression level of resulting image in range 0-100; 00510 * quality - output quality. 00511 * RETURN VALUE 00512 * New ASImage on success, NULL on failure. 00513 * SEE ALSO 00514 * scale_asimage(), tile_asimage() 00515 *********/ 00516 00517 Bool 00518 colorize_asimage_vector( ASVisual *asv, ASImage *im, 00519 ASVectorPalette *palette, 00520 ASAltImFormats out_format, 00521 int quality ); 00522 ASImage * 00523 create_asimage_from_vector( ASVisual *asv, double *vector, 00524 int width, int height, 00525 ASVectorPalette *palette, 00526 ASAltImFormats out_format, 00527 unsigned int compression, int quality ); 00528 ASImage* 00529 slice_asimage2( ASVisual *asv, ASImage *src, 00530 int slice_x_start, int slice_x_end, 00531 int slice_y_start, int slice_y_end, 00532 int to_width, 00533 int to_height, 00534 Bool scaled, /* middle portion */ 00535 ASAltImFormats out_format, 00536 unsigned int compression_out, int quality ); 00537 00538 /* same as above with scale = 0 */ 00539 ASImage* 00540 slice_asimage (ASVisual *asv, ASImage *src, 00541 int slice_x_start, int slice_x_end, 00542 int slice_y_start, int slice_y_end, 00543 int to_width, 00544 int to_height, 00545 ASAltImFormats out_format, 00546 unsigned int compression_out, int quality); 00547 00548 ASImage * 00549 pixelize_asimage (ASVisual *asv, ASImage *src, 00550 int clip_x, int clip_y, int clip_width, int clip_height, 00551 int pixel_width, int pixel_height, 00552 ASAltImFormats out_format, unsigned int compression_out, int quality ); 00553 ASImage * 00554 color2alpha_asimage (ASVisual *asv, ASImage *src, 00555 int clip_x, int clip_y, int clip_width, int clip_height, 00556 ARGB32 color, 00557 ASAltImFormats out_format, unsigned int compression_out, int quality); 00558 00559 #ifdef __cplusplus 00560 } 00561 #endif 00562 00563 #endif