1999-08-01 15:14:11 -07:00
# include <X11/Xlib.h>
# include <X11/extensions/XShm.h>
# include <X11/Xutil.h>
# include <X11/extensions/shape.h>
# include <X11/Xatom.h>
# include <X11/Xos.h>
1999-08-05 19:08:36 -07:00
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <unistd.h>
2000-03-03 08:42:18 -08:00
# include <math.h>
2000-12-12 13:07:38 -08:00
# include <locale.h>
2000-05-21 20:25:24 -07:00
1999-08-05 19:08:36 -07:00
/*
1999-08-01 15:14:11 -07:00
# include <sys/time.h>
# include "common.h"
# include "image.h"
# include "rend.h"
# include "rgba.h"
1999-08-05 19:08:36 -07:00
# include "ximage.h"
# include "color.h"
*/
1999-11-01 09:49:58 -08:00
# include "Imlib2.h"
1999-08-01 15:14:11 -07:00
Display * disp ;
1999-09-10 11:11:47 -07:00
Window win ;
Visual * vis ;
Colormap cm ;
int depth ;
1999-10-22 04:19:11 -07:00
void progress ( Imlib_Image * im , char percent , int update_x , int update_y ,
2000-05-05 09:28:39 -07:00
int update_w , int update_h ) ;
1999-10-22 04:19:11 -07:00
1999-09-12 18:56:57 -07:00
void
1999-09-10 11:11:47 -07:00
progress ( Imlib_Image * im , char percent ,
int update_x , int update_y ,
int update_w , int update_h )
{
1999-12-07 10:02:47 -08:00
imlib_context_set_display ( disp ) ;
imlib_context_set_visual ( vis ) ;
imlib_context_set_colormap ( cm ) ;
imlib_context_set_drawable ( win ) ;
imlib_context_set_dither ( 0 ) ;
imlib_context_set_blend ( 0 ) ;
imlib_context_set_color_modifier ( NULL ) ;
imlib_context_set_operation ( IMLIB_OP_COPY ) ;
imlib_context_set_image ( im ) ;
imlib_render_image_part_on_drawable_at_size ( update_x , update_y ,
1999-09-10 11:11:47 -07:00
update_w , update_h ,
1999-09-12 18:56:57 -07:00
update_x , update_y ,
1999-12-07 10:02:47 -08:00
update_w , update_h ) ;
1999-09-10 11:11:47 -07:00
}
1999-08-01 15:14:11 -07:00
int main ( int argc , char * * argv )
{
int i , j ;
1999-10-22 04:19:11 -07:00
Imlib_Image * im = NULL ;
1999-08-01 15:14:11 -07:00
int sec1 , usec1 , sec2 , usec2 ;
int pixels = 0 ;
struct timeval timev ;
double sec ;
1999-09-14 18:15:55 -07:00
char * file = NULL ;
1999-09-27 15:52:02 -07:00
char * fon = NULL , * str = NULL ;
1999-08-01 15:14:11 -07:00
int root = 0 ;
int scale = 0 ;
1999-09-12 18:56:57 -07:00
int w = 20 ;
int h = 20 ;
1999-08-01 15:14:11 -07:00
int aa = 0 ;
int dith = 0 ;
1999-09-12 18:56:57 -07:00
int loop = 0 ;
int blend = 1 ;
int interactive = 1 ;
1999-09-13 21:21:29 -07:00
int blendtest = 0 ;
2000-04-13 09:31:51 -07:00
int filter = 0 ;
2001-01-25 19:29:55 -08:00
int pol = 0 ;
2000-02-27 10:36:26 -08:00
int rotate = 0 ;
int rottest = 0 ;
2000-03-28 14:25:45 -08:00
int scaleup = 0 ;
2000-04-20 15:29:10 -07:00
int scaleboth = 0 ;
int origone = 0 ;
2000-05-21 12:20:53 -07:00
int bump_map_to_point = 0 ;
2000-05-05 09:28:39 -07:00
Imlib_Color_Modifier colormod = 0 ;
2000-08-30 12:52:57 -07:00
ImlibPolygon poly , poly2 , poly3 ;
2000-12-12 13:07:38 -08:00
int textdir = IMLIB_TEXT_TO_RIGHT ;
int xfdtest = 0 ;
int xfdcachetest = 0 ;
char * xfdfname = NULL ;
int xfdloop = 1 ;
/* now we'll set the locale */
setlocale ( LC_ALL , " " ) ;
if ( ! XSupportsLocale ( ) )
setlocale ( LC_ALL , " C " ) ;
XSetLocaleModifiers ( " " ) ;
setlocale ( LC_ALL , NULL ) ;
2000-05-05 09:28:39 -07:00
2000-04-28 10:42:49 -07:00
/**
* Parse all the command line arguments
*/
2000-05-05 09:28:39 -07:00
if ( ( argc > 1 ) & & ( ! strcmp ( argv [ 1 ] , " -help " ) ) )
2000-04-28 10:42:49 -07:00
{
2000-05-05 09:28:39 -07:00
printf ( " Imlib2 program test. (Imlib v2.0.0.4) \n " ) ;
printf ( " usage: imlib2 [options] [file] \n " ) ;
printf ( " options are: \n " ) ;
printf ( " -help \t \t Displays this help. \n " ) ;
printf ( " -root \t \t Draw in the root window. \n " ) ;
printf ( " -smooth \t \t When scaling images scale with anti-aliasing. \n " ) ;
printf ( " -up \t \t When doing scal test scale up, not down. \n " ) ;
printf ( " -both \t \t Scale horizontally AND vertically in scale test. \n " ) ;
printf ( " -orig \t \t Keep original width and height in each pass of scale test. \n " ) ;
printf ( " -blend \t \t Blending test. \n " ) ;
printf ( " -dither \t \t Turn dithering on for depths < 24bpp \n " ) ;
printf ( " -colormod <r> <g> <b> <a> \t \t Set up color mod tables \n " ) ;
printf ( " -scale \t \t Scale test. \n " ) ;
printf ( " -noloop \t \t Dont loop - timing test. \n " ) ;
printf ( " -rotate \t \t Also rotate background image with mouse in interative test. \n " ) ;
printf ( " -size <w> <h> \t \t Scale from w x h down in scaling test. \n " ) ; // require parameters w / h
printf ( " -maxcolors <n> \t \t Limit color allocation count to n colors. \n " ) ; // require parameter nb colors
printf ( " -text \t \t Displays the text following this option. Need a loaded font. \n " ) ;
2000-12-12 13:07:38 -08:00
printf ( " -font \t \t Loads a font. The parameter must follow the police_name/size format. Example: loading the grunge font at size 18 is : grunge/18. \n \t \t The XFD font also can be specified. Ex. 'notepad/32,-*--24-*'. \n " ) ;
2001-01-25 19:29:55 -08:00
printf ( " -poly \t \t Performs a poly test \n " ) ;
2000-05-05 09:28:39 -07:00
printf ( " The following options requires a file to work properly. \n " ) ;
2000-12-12 13:07:38 -08:00
printf ( " -textdir \t \t Text Direction. 0: L to R, 1: R to L \n " ) ;
printf ( " 2: U to D, 3: D to U, 4: angle \n " ) ;
printf ( " -xfdtest \t \t XFD Font queue test. \n " ) ;
printf ( " -xfdcachetest <f> [<l>] \t \t XFD tFont cache test. \n \t \t The file f is drawn l times \n " ) ;
2000-05-05 09:28:39 -07:00
printf ( " -blast \t \t Displays the file. \n " ) ;
printf ( " -loop \t \t Scales down the image. \n " ) ;
printf ( " -blendtest \t Performs a blending test on the file. \n " ) ;
printf ( " -rotatetest \t Performs a rotate test on the file. \n " ) ;
printf ( " -filter \t \t Performs filtering. Possible filters are, \n \t \t \t 1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n \t \t \t 4:Emboss filter, 5:Grayscale filter, 6:Saturation filter, \n \t \t \t 7:Edge detection filter. \n " ) ;
2000-05-21 12:20:53 -07:00
printf ( " -bmp2pt \t \t Performas Bump Mapping to a point \n " ) ;
2000-05-05 09:28:39 -07:00
return 0 ;
2000-04-28 10:42:49 -07:00
}
2000-05-05 09:28:39 -07:00
1999-08-01 15:14:11 -07:00
for ( i = 1 ; i < argc ; i + + )
{
2000-05-05 09:28:39 -07:00
if ( ! strcmp ( argv [ i ] , " -root " ) )
root = 1 ;
else if ( ! strcmp ( argv [ i ] , " -smooth " ) )
aa = 1 ;
else if ( ! strcmp ( argv [ i ] , " -blast " ) )
1999-10-30 04:22:48 -07:00
interactive = 0 ;
2000-05-05 09:28:39 -07:00
else if ( ! strcmp ( argv [ i ] , " -loop " ) )
{
interactive = 0 ;
loop = 1 ;
}
else if ( ! strcmp ( argv [ i ] , " -up " ) )
scaleup = 1 ;
else if ( ! strcmp ( argv [ i ] , " -both " ) )
scaleboth = 1 ;
2000-05-21 12:20:53 -07:00
else if ( ! strcmp ( argv [ i ] , " -bmp2pt " ) )
bump_map_to_point = 1 ;
2000-05-05 09:28:39 -07:00
else if ( ! strcmp ( argv [ i ] , " -orig " ) )
2000-04-20 15:29:10 -07:00
origone = 1 ;
1999-08-01 15:14:11 -07:00
else if ( ! strcmp ( argv [ i ] , " -blend " ) )
2000-05-05 09:28:39 -07:00
blend = 1 ;
2001-01-25 19:29:55 -08:00
else if ( ! strcmp ( argv [ i ] , " -poly " ) )
pol = 1 ;
2000-05-05 09:28:39 -07:00
else if ( ! strcmp ( argv [ i ] , " -blendtest " ) )
{
blendtest = 1 ;
interactive = 0 ;
2000-02-27 10:36:26 -08:00
}
2000-05-05 09:28:39 -07:00
else if ( ! strcmp ( argv [ i ] , " -colormod " ) )
{
DATA8 rt [ 256 ] , gt [ 256 ] , bt [ 256 ] , at [ 256 ] ;
double rm , gm , bm , am ;
int j ;
/*\ Setup color mod tables \*/
if ( ! colormod ) colormod = imlib_create_color_modifier ( ) ;
imlib_context_set_color_modifier ( colormod ) ;
rm = strtod ( argv [ + + i ] , 0 ) ;
gm = strtod ( argv [ + + i ] , 0 ) ;
bm = strtod ( argv [ + + i ] , 0 ) ;
am = strtod ( argv [ + + i ] , 0 ) ;
imlib_get_color_modifier_tables ( rt , gt , bt , at ) ;
for ( j = 0x100 ; - - j > = 0 ; ) {
rt [ j ] = ( ( double ) rt [ j ] ) * rm ;
gt [ j ] = ( ( double ) gt [ j ] ) * gm ;
bt [ j ] = ( ( double ) bt [ j ] ) * bm ;
at [ j ] = ( ( double ) at [ j ] ) * am ;
}
imlib_set_color_modifier_tables ( rt , gt , bt , at ) ;
}
else if ( ! strcmp ( argv [ i ] , " -dither " ) )
dith = 1 ;
else if ( ! strcmp ( argv [ i ] , " -scale " ) )
scale = 1 ;
else if ( ! strcmp ( argv [ i ] , " -noloop " ) )
loop = 0 ;
else if ( ! strcmp ( argv [ i ] , " -size " ) )
{
i + + ;
w = atoi ( argv [ i + + ] ) ;
h = atoi ( argv [ i ] ) ;
}
else if ( ! strcmp ( argv [ i ] , " -maxcolors " ) )
{
i + + ;
imlib_set_color_usage ( atoi ( argv [ i ] ) ) ;
}
else if ( ! strcmp ( argv [ i ] , " -font " ) )
{
i + + ;
fon = argv [ i ] ;
}
else if ( ! strcmp ( argv [ i ] , " -text " ) )
{
i + + ;
str = argv [ i ] ;
}
2000-12-12 13:07:38 -08:00
else if ( ! strcmp ( argv [ i ] , " -xfdtest " ) )
xfdtest = 1 ;
else if ( ! strcmp ( argv [ i ] , " -xfdcachetest " ) )
{
xfdcachetest = 1 ;
i + + ;
xfdfname = argv [ i ] ;
i + + ;
if ( i < argc )
xfdloop = atoi ( argv [ i ] ) ;
}
else if ( ! strcmp ( argv [ i ] , " -textdir " ) )
{
i + + ;
textdir = atoi ( argv [ i ] ) ;
}
2000-05-05 09:28:39 -07:00
else if ( ! strcmp ( argv [ i ] , " -rotate " ) )
rotate = 1 ;
else if ( ! strcmp ( argv [ i ] , " -filter " ) )
{
filter = atoi ( argv [ + + i ] ) ;
interactive = 0 ;
}
else if ( ! strcmp ( argv [ i ] , " -rotatetest " ) )
{
rottest = 1 ;
interactive = 0 ;
}
else
file = argv [ i ] ;
1999-08-01 15:14:11 -07:00
}
2000-05-05 09:28:39 -07:00
2000-04-28 10:42:49 -07:00
/**
* Initialization according to options
*/
1999-08-01 15:14:11 -07:00
printf ( " init \n " ) ;
2000-05-05 09:28:39 -07:00
2000-04-28 10:42:49 -07:00
/**
* First tests to determine which rendering task to perform
*/
2000-03-27 11:17:37 -08:00
if ( ! blendtest )
1999-09-26 14:36:51 -07:00
{
2000-03-27 11:17:37 -08:00
disp = XOpenDisplay ( NULL ) ;
vis = DefaultVisual ( disp , DefaultScreen ( disp ) ) ;
depth = DefaultDepth ( disp , DefaultScreen ( disp ) ) ;
cm = DefaultColormap ( disp , DefaultScreen ( disp ) ) ;
/* nasty - using imlib internal function.. but it makes benchmarks fair */
if ( ! interactive )
__imlib_SetMaxXImageCount ( disp , 3 ) ;
if ( root )
win = DefaultRootWindow ( disp ) ;
else
{
win = XCreateSimpleWindow ( disp , DefaultRootWindow ( disp ) , 0 , 0 , 10 , 10 , 0 , 0 , 0 ) ;
XSelectInput ( disp , win , ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | PointerMotionMask | ExposureMask ) ;
}
1999-09-26 14:36:51 -07:00
}
2000-05-05 09:28:39 -07:00
1999-09-12 18:56:57 -07:00
if ( ! interactive )
1999-08-01 15:14:11 -07:00
{
2000-04-16 11:26:16 -07:00
printf ( " load %s \n " , file ) ;
1999-12-19 15:02:56 -08:00
im = imlib_load_image_immediately ( file ) ;
1999-09-12 18:56:57 -07:00
if ( ! im )
{
2000-04-28 10:42:49 -07:00
printf ( " load failed \n " ) ;
1999-09-12 18:56:57 -07:00
exit ( 0 ) ;
}
1999-12-07 10:02:47 -08:00
imlib_context_set_image ( im ) ;
w = imlib_image_get_width ( ) ;
h = imlib_image_get_height ( ) ;
2000-04-16 11:26:16 -07:00
printf ( " image %i x %i \n " , w , h ) ;
1999-08-01 15:14:11 -07:00
}
2000-05-05 09:28:39 -07:00
2000-03-27 11:17:37 -08:00
if ( ! blendtest )
1999-08-01 15:14:11 -07:00
{
2000-03-27 11:17:37 -08:00
if ( ! root )
{
2000-03-28 14:25:45 -08:00
if ( scaleup )
XResizeWindow ( disp , win , w * 4 , h * 4 ) ;
2000-04-26 19:32:28 -07:00
else if ( scaleboth )
XResizeWindow ( disp , win , w * 2 , h * 2 ) ;
2000-03-28 14:25:45 -08:00
else
XResizeWindow ( disp , win , w , h ) ;
2000-03-27 11:17:37 -08:00
XMapWindow ( disp , win ) ;
}
if ( scale )
{
Window d ;
int dd ;
2000-04-16 11:26:16 -07:00
XGetGeometry ( disp , win , & d , & dd , & dd , & dd , & dd , & dd , & dd ) ;
2000-03-27 11:17:37 -08:00
}
XSync ( disp , False ) ;
1999-08-01 15:14:11 -07:00
}
2000-05-05 09:28:39 -07:00
2000-04-28 10:42:49 -07:00
/**
* Start rendering
*/
1999-08-01 15:14:11 -07:00
printf ( " rend \n " ) ;
2000-05-05 09:28:39 -07:00
2000-03-27 11:17:37 -08:00
if ( ! blendtest )
{
imlib_context_set_display ( disp ) ;
imlib_context_set_visual ( vis ) ;
imlib_context_set_colormap ( cm ) ;
imlib_context_set_drawable ( win ) ;
}
1999-12-07 10:02:47 -08:00
imlib_context_set_anti_alias ( aa ) ;
imlib_context_set_dither ( dith ) ;
imlib_context_set_blend ( blend ) ;
imlib_context_set_color_modifier ( NULL ) ;
imlib_context_set_operation ( IMLIB_OP_COPY ) ;
imlib_context_set_image ( im ) ;
1999-09-27 15:52:02 -07:00
2000-03-28 14:25:45 -08:00
gettimeofday ( & timev , NULL ) ;
sec1 = ( int ) timev . tv_sec ; /* and stores it so we can time outselves */
usec1 = ( int ) timev . tv_usec ; /* we will use this to vary speed of rot */
2000-08-30 12:52:57 -07:00
2000-09-03 12:14:02 -07:00
poly = imlib_polygon_new ( ) ;
2000-08-30 12:52:57 -07:00
imlib_polygon_add_point ( poly , 400 , 50 ) ;
imlib_polygon_add_point ( poly , 450 , 100 ) ;
imlib_polygon_add_point ( poly , 350 , 100 ) ;
2000-09-03 12:14:02 -07:00
poly2 = imlib_polygon_new ( ) ;
2000-08-30 12:52:57 -07:00
imlib_polygon_add_point ( poly2 , 400 , 150 ) ;
imlib_polygon_add_point ( poly2 , 450 , 200 ) ;
imlib_polygon_add_point ( poly2 , 350 , 200 ) ;
2000-09-03 12:14:02 -07:00
poly3 = imlib_polygon_new ( ) ;
2000-08-30 12:52:57 -07:00
imlib_polygon_add_point ( poly3 , 400 , 250 ) ;
imlib_polygon_add_point ( poly3 , 450 , 300 ) ;
imlib_polygon_add_point ( poly3 , 350 , 300 ) ;
2000-09-03 11:04:00 -07:00
Commiting what I have so far. More to do tomorrow, but it's 3am.
Polygons are now filled with antialiasing, if context_antialias is set.
So are ellipses.
I fixed some clipping bugs.
There is a bug with the AA span though, it's just a little one, but I'm too
tired to find it now. You will see it if you look closely at the top of the
filled ellipse in test/imlib2, using xmag or something.
I'll fix that tomorrow, speed things up a bit, and hopefully implement AA
drawing for ellipse outlines. Oh, I'll unroll some more loops too.
raster: your last commit broke the two test apps. a segv in _RGBA_init()
somewhere, I know it's not my new code, as I tried a fresh checkout and it
did the same thing. I don't have time to check it out tonight though.
SVN revision: 3498
2000-09-16 18:57:01 -07:00
2001-01-25 19:29:55 -08:00
# define A90 (3.141592654 / 2)
if ( pol )
{
Imlib_Image im_bg , im ;
int w , h ;
int i ;
double a , points [ 8 ] [ 2 ] ;
if ( file )
im_bg = imlib_load_image ( file ) ;
else
im_bg = imlib_load_image ( " test_images/bg.png " ) ;
imlib_context_set_image ( im_bg ) ;
w = imlib_image_get_width ( ) ;
h = imlib_image_get_height ( ) ;
XResizeWindow ( disp , win , w , h ) ;
XSync ( disp , False ) ;
im = imlib_create_image ( w , h ) ;
srand ( time ( NULL ) ) ;
for ( i = 0 ; i < 8 ; i + + )
{
points [ i ] [ 0 ] = ( rand ( ) % w ) - ( w / 2 ) ;
points [ i ] [ 1 ] = ( rand ( ) % h ) - ( h / 2 ) ;
}
a = 0.0 ;
for ( ; ; )
{
imlib_context_set_image ( im ) ;
imlib_blend_image_onto_image ( im_bg , 0 , 0 , 0 , w , h , 0 , 0 , w , h ) ;
poly = imlib_polygon_new ( ) ;
for ( i = 0 ; i < 8 ; i + + )
{
double xx , yy ;
xx = ( w / 2 ) +
( cos ( a ) * points [ i ] [ 0 ] ) +
( cos ( a + A90 ) * points [ i ] [ 1 ] ) ;
yy = ( h / 2 ) +
( sin ( a ) * points [ i ] [ 0 ] ) +
( sin ( a + A90 ) * points [ i ] [ 1 ] ) ;
imlib_polygon_add_point ( poly , xx , yy ) ;
}
printf ( " draw angle %3.3f \n " , a ) ;
imlib_context_set_color ( 255 , 255 , 255 , 100 ) ;
imlib_image_fill_polygon ( poly ) ;
imlib_context_set_color ( 0 , 0 , 0 , 20 ) ;
imlib_image_draw_polygon ( poly , 1 ) ;
imlib_polygon_free ( poly ) ;
imlib_render_image_on_drawable ( 0 , 0 ) ;
a + = 0.05 ;
}
}
1999-08-01 15:14:11 -07:00
if ( loop )
{
2000-04-16 11:26:16 -07:00
printf ( " loop \n " ) ;
2000-05-05 09:28:39 -07:00
2000-04-28 10:42:49 -07:00
// first test
2000-03-28 14:25:45 -08:00
if ( scaleup )
{
2000-04-16 11:26:16 -07:00
printf ( " scale up \n " ) ;
2000-03-28 14:25:45 -08:00
for ( i = 0 ; i < w * 3 ; i + = 8 )
{
if ( ! blendtest )
2000-04-20 15:29:10 -07:00
{
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
w + i , ( ( ( w + i ) * h ) / w ) ) ;
if ( im_tmp )
{
imlib_context_set_image ( im_tmp ) ;
imlib_render_image_on_drawable ( 0 , 0 ) ;
imlib_free_image ( ) ;
}
imlib_context_set_image ( im ) ;
}
2000-03-28 14:25:45 -08:00
else
{
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
w + i , ( ( ( w + i ) * h ) / w ) ) ;
if ( im_tmp )
{
imlib_context_set_image ( im_tmp ) ;
imlib_free_image ( ) ;
}
imlib_context_set_image ( im ) ;
}
2000-04-20 15:29:10 -07:00
pixels + = ( w + i ) * ( ( ( w + i ) * h ) / w ) ;
}
}
2000-05-05 09:28:39 -07:00
2000-04-28 10:42:49 -07:00
// else if // second
2000-04-20 15:29:10 -07:00
else if ( scaleboth )
{
if ( origone )
{
for ( i = 0 ; i < w * 2 ; i + = 4 )
{
if ( ! blendtest )
{
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
2000-05-05 09:28:39 -07:00
w , ( ( ( i ) * h ) / w ) ) ;
2000-04-20 15:29:10 -07:00
if ( im_tmp )
{
imlib_context_set_image ( im_tmp ) ;
imlib_render_image_on_drawable ( 0 , 0 ) ;
imlib_free_image ( ) ;
}
imlib_context_set_image ( im ) ;
}
else
{
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
w , ( ( ( i ) * h ) / w ) ) ;
if ( im_tmp )
{
imlib_context_set_image ( im_tmp ) ;
imlib_free_image ( ) ;
}
imlib_context_set_image ( im ) ;
}
XSync ( disp , False ) ;
pixels + = ( 2 * w - i ) * ( ( ( i ) * h ) / w ) ;
}
for ( i = 0 ; i < w * 2 ; i + = 4 )
{
if ( ! blendtest )
imlib_render_image_on_drawable_at_size ( 0 , 0 ,
2 * w - i , h ) ;
else
{
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
2 * w - i , h ) ;
if ( im_tmp )
{
imlib_context_set_image ( im_tmp ) ;
imlib_free_image ( ) ;
}
imlib_context_set_image ( im ) ;
}
pixels + = ( 2 * w - i ) * h ;
}
}
else
{
for ( i = 0 ; i < w * 2 ; i + = 4 )
{
if ( ! blendtest )
imlib_render_image_on_drawable_at_size ( 0 , 0 ,
2 * w - i , ( ( ( i ) * h ) / w ) ) ;
else
{
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
2 * w - i , ( ( ( i ) * h ) / w ) ) ;
if ( im_tmp )
{
imlib_context_set_image ( im_tmp ) ;
imlib_free_image ( ) ;
}
imlib_context_set_image ( im ) ;
}
pixels + = w * ( ( ( i ) * h ) / w ) ;
}
2000-03-28 14:25:45 -08:00
}
}
else
1999-08-01 15:14:11 -07:00
{
2000-05-05 09:28:39 -07:00
printf ( " scale down 0 -> %i incriment by 1 \n " , w ) ;
2000-03-28 14:25:45 -08:00
for ( i = 0 ; i < w ; i + + )
{
if ( ! blendtest )
imlib_render_image_on_drawable_at_size ( 0 , 0 ,
w - i , ( ( ( w - i ) * h ) / w ) ) ;
else
{
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
w - i , ( ( ( w - i ) * h ) / w ) ) ;
if ( im_tmp )
{
imlib_context_set_image ( im_tmp ) ;
imlib_free_image ( ) ;
}
imlib_context_set_image ( im ) ;
}
2000-04-26 19:32:28 -07:00
pixels + = ( w + i ) * ( ( ( w + i ) * h ) / w ) ;
}
}
2000-04-28 10:42:49 -07:00
}
2000-05-05 09:28:39 -07:00
// last test
/* else if (scaleboth)
{
for ( i = 0 ; i < w * 2 ; i + = 1 )
2000-04-26 19:32:28 -07:00
{
2000-05-05 09:28:39 -07:00
if ( ! blendtest )
imlib_render_image_on_drawable_at_size ( 0 , 0 ,
2 * w - i , ( ( ( i ) * h ) / w ) ) ;
else
2000-04-26 19:32:28 -07:00
{
2000-05-05 09:28:39 -07:00
Imlib_Image im_tmp ;
im_tmp = imlib_create_cropped_scaled_image ( 0 , 0 , w , h ,
2 * w - i , ( ( ( i ) * h ) / w ) ) ;
if ( im_tmp )
2000-04-26 19:32:28 -07:00
{
2000-05-05 09:28:39 -07:00
imlib_context_set_image ( im_tmp ) ;
imlib_free_image ( ) ;
2000-04-26 19:32:28 -07:00
}
2000-05-05 09:28:39 -07:00
imlib_context_set_image ( im ) ;
2000-03-28 14:25:45 -08:00
}
2000-05-05 09:28:39 -07:00
pixels + = ( 2 * w - i ) * ( ( ( i ) * h ) / w ) ;
1999-08-01 15:14:11 -07:00
}
2000-05-05 09:28:39 -07:00
}
} */ // end if loop
1999-09-13 21:21:29 -07:00
else if ( blendtest )
{
Imlib_Image im2 ;
2000-05-05 09:28:39 -07:00
1999-09-13 21:21:29 -07:00
im2 = imlib_create_image ( w , h ) ;
1999-12-07 10:02:47 -08:00
imlib_context_set_image ( im2 ) ;
w = imlib_image_get_width ( ) ;
h = imlib_image_get_height ( ) ;
2000-03-27 11:17:37 -08:00
imlib_context_set_image ( im2 ) ;
2000-05-05 09:28:39 -07:00
imlib_context_set_color_modifier ( colormod ) ;
2000-03-27 11:17:37 -08:00
for ( i = 0 ; i < 256 ; i + + )
1999-09-13 21:21:29 -07:00
{
2000-03-27 11:17:37 -08:00
imlib_blend_image_onto_image ( im , 0 , 0 , 0 , w , h , 0 , 0 , w , h ) ;
1999-09-13 21:21:29 -07:00
pixels + = ( w * h ) ;
}
}
2000-03-03 09:24:46 -08:00
else if ( rottest )
2000-02-27 10:36:26 -08:00
{
2000-05-05 09:28:39 -07:00
int w , h ;
double i ;
2000-02-27 10:36:26 -08:00
imlib_context_set_image ( im ) ;
imlib_render_image_on_drawable ( 0 , 0 ) ;
2000-03-03 09:24:46 -08:00
w = imlib_image_get_width ( ) ;
h = imlib_image_get_height ( ) ;
printf ( " rotating inside %dx%d frame \n " , w , h ) ;
2000-02-27 10:36:26 -08:00
2000-03-03 09:24:46 -08:00
imlib_context_set_blend ( 1 ) ;
imlib_context_set_image ( imlib_create_image ( w , h ) ) ;
2000-05-05 09:28:39 -07:00
for ( i = 0 ; i < 1 ; i + = 0.01 ) {
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image ( im , 0 , 0 , 0 , w , h , 0 , 0 , w , h ) ;
2000-05-05 09:28:39 -07:00
imlib_context_set_color_modifier ( colormod ) ;
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image_at_angle ( im , 0 , 0 , 0 , w , h ,
2000-05-05 09:28:39 -07:00
0 , h * i ,
w * ( 1 - i ) , - ( h * i ) ) ;
imlib_context_set_color_modifier ( NULL ) ;
2000-02-27 10:36:26 -08:00
imlib_render_image_on_drawable ( 0 , 0 ) ;
2000-03-03 09:24:46 -08:00
pixels + = w * h ;
2000-03-01 09:04:23 -08:00
}
2000-05-05 09:28:39 -07:00
for ( i = 0 ; i < 1 ; i + = 0.01 ) {
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image ( im , 0 , 0 , 0 , w , h , 0 , 0 , w , h ) ;
2000-05-05 09:28:39 -07:00
imlib_context_set_color_modifier ( colormod ) ;
imlib_context_set_operation ( IMLIB_OP_ADD ) ;
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image_at_angle ( im , 0 , 0 , 0 , w , h ,
2000-05-05 09:28:39 -07:00
w * i , h ,
- ( w * i ) , h * ( i - 1 ) ) ;
imlib_context_set_operation ( IMLIB_OP_COPY ) ;
imlib_context_set_color_modifier ( NULL ) ;
2000-03-03 09:24:46 -08:00
imlib_render_image_on_drawable ( 0 , 0 ) ;
pixels + = w * h ;
}
2000-05-05 09:28:39 -07:00
for ( i = 0 ; i < 1 ; i + = 0.01 ) {
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image ( im , 0 , 0 , 0 , w , h , 0 , 0 , w , h ) ;
2000-05-05 09:28:39 -07:00
imlib_context_set_color_modifier ( colormod ) ;
imlib_context_set_operation ( IMLIB_OP_SUBTRACT ) ;
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image_at_angle ( im , 0 , 0 , 0 , w , h ,
2000-05-05 09:28:39 -07:00
w , h * ( 1 - i ) ,
w * ( i - 1 ) , h * i ) ;
imlib_context_set_operation ( IMLIB_OP_COPY ) ;
imlib_context_set_color_modifier ( NULL ) ;
2000-03-03 09:24:46 -08:00
imlib_render_image_on_drawable ( 0 , 0 ) ;
pixels + = w * h ;
}
2000-05-05 09:28:39 -07:00
for ( i = 0 ; i < 1 ; i + = 0.01 ) {
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image ( im , 0 , 0 , 0 , w , h , 0 , 0 , w , h ) ;
2000-05-05 09:28:39 -07:00
imlib_context_set_color_modifier ( colormod ) ;
imlib_context_set_operation ( IMLIB_OP_RESHADE ) ;
2000-03-03 09:24:46 -08:00
imlib_blend_image_onto_image_at_angle ( im , 0 , 0 , 0 , w , h ,
2000-05-05 09:28:39 -07:00
w * ( 1 - i ) , 0 ,
w * i , h * ( 1 - i ) ) ;
imlib_context_set_operation ( IMLIB_OP_COPY ) ;
imlib_context_set_color_modifier ( NULL ) ;
2000-03-01 09:04:23 -08:00
imlib_render_image_on_drawable ( 0 , 0 ) ;
2000-03-03 09:24:46 -08:00
pixels + = w * h ;
2000-02-27 10:36:26 -08:00
}
2000-03-03 09:24:46 -08:00
imlib_free_image ( ) ;
2000-02-27 10:36:26 -08:00
}
2000-04-13 09:31:51 -07:00
else if ( filter )
{
imlib_context_set_filter ( imlib_create_filter ( 0 ) ) ;
switch ( filter ) {
default :
case 1 :
/*\ Blur filter \*/
imlib_filter_set ( 0 , 0 , 0 , 8 , 8 , 8 ) ;
imlib_filter_set ( - 1 , 0 , 0 , 4 , 4 , 4 ) ;
imlib_filter_set ( 0 , - 1 , 0 , 4 , 4 , 4 ) ;
imlib_filter_set ( 1 , 0 , 0 , 4 , 4 , 4 ) ;
imlib_filter_set ( 0 , 1 , 0 , 4 , 4 , 4 ) ;
imlib_filter_set ( - 2 , 0 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set ( 0 , - 2 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set ( 2 , 0 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set ( 0 , 2 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set ( - 1 , - 1 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set ( - 1 , 1 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set ( 1 , - 1 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set ( 1 , 1 , 0 , 1 , 1 , 1 ) ;
break ;
case 2 :
/*\ Sharpen filter \*/
imlib_filter_set ( 0 , 0 , 0 , 5 , 5 , 5 ) ;
imlib_filter_set ( - 1 , 0 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set ( 0 , - 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set ( 1 , 0 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set ( 0 , 1 , 0 , - 1 , - 1 , - 1 ) ;
break ;
case 3 :
/*\ Color blur filter \*/
imlib_filter_set ( 0 , 0 , 0 , 3 , 3 , 3 ) ;
imlib_filter_set ( - 1 , - 1 , 0 , 1 , 0 , 0 ) ;
imlib_filter_set ( 1 , - 1 , 0 , 0 , 1 , 0 ) ;
imlib_filter_set ( 0 , 1 , 0 , 0 , 0 , 1 ) ;
break ;
case 4 :
/*\ Emboss filter \*/
imlib_filter_set_red ( - 1 , - 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set_red ( 0 , 0 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set_green ( - 1 , - 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set_green ( 0 , 0 , 0 , 1 , 1 , 1 ) ;
imlib_filter_set_blue ( - 1 , - 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set_blue ( 0 , 0 , 0 , 1 , 1 , 1 ) ;
2000-05-05 09:28:39 -07:00
2000-04-16 11:26:16 -07:00
imlib_filter_constants ( 0 , 768 , 768 , 768 ) ;
imlib_filter_divisors ( 0 , 6 , 6 , 6 ) ;
2000-04-13 09:31:51 -07:00
break ;
case 5 :
/*\ Grayscale filter \*/
imlib_filter_set_red ( 0 , 0 , 0 , 80 , 1 , 1 ) ;
imlib_filter_set_green ( 0 , 0 , 0 , 1 , 80 , 1 ) ;
imlib_filter_set_blue ( 0 , 0 , 0 , 1 , 1 , 80 ) ;
break ;
case 6 :
/*\ Saturation filter \*/
imlib_filter_set_red ( 0 , 0 , 0 , 80 , - 1 , - 1 ) ;
imlib_filter_set_green ( 0 , 0 , 0 , - 1 , 80 , - 1 ) ;
imlib_filter_set_blue ( 0 , 0 , 0 , - 1 , - 1 , 80 ) ;
break ;
2000-04-16 11:26:16 -07:00
case 7 :
/*\ Edge detection filter \*/
imlib_filter_set ( - 1 , - 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set ( - 1 , 0 , 0 , - 3 , - 3 , - 3 ) ;
imlib_filter_set ( - 1 , 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set ( 0 , - 1 , 0 , - 3 , - 3 , - 3 ) ;
imlib_filter_set ( 0 , 0 , 0 , 16 , 16 , 16 ) ;
imlib_filter_set ( 0 , 1 , 0 , - 3 , - 3 , - 3 ) ;
imlib_filter_set ( 1 , - 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_set ( 1 , 0 , 0 , - 3 , - 3 , - 3 ) ;
imlib_filter_set ( 1 , 1 , 0 , - 1 , - 1 , - 1 ) ;
imlib_filter_divisors ( 0 , 3 , 3 , 3 ) ;
2000-04-13 09:31:51 -07:00
}
pixels = 0 ;
imlib_render_image_on_drawable_at_size ( 0 , 0 , w , h ) ;
for ( i = 0 ; i < w ; i + + )
{
imlib_image_filter ( ) ;
imlib_render_image_on_drawable_at_size ( 0 , 0 , w , h ) ;
pixels + = w * h ;
}
imlib_free_filter ( ) ;
}
1999-09-08 10:27:40 -07:00
else if ( interactive )
{
1999-09-26 14:36:51 -07:00
int wo , ho , px , py , first = 1 ;
Imlib_Image im_bg , im_sh1 , im_sh2 , im_sh3 , im_ic [ 13 ] , im_tmp ;
1999-10-22 04:19:11 -07:00
/* Imlib_Border border; */
1999-09-26 14:36:51 -07:00
Imlib_Updates up = NULL ;
1999-12-07 10:02:47 -08:00
int x , y , i , j ;
1999-09-26 14:36:51 -07:00
XEvent ev ;
1999-10-22 04:19:11 -07:00
Imlib_Font fn = NULL ;
2000-12-12 13:07:38 -08:00
struct font_hdr
{
int type ;
struct font_hdr * next ;
char * name ;
int ref ;
XFontSet xfontset ;
int font_count ;
XFontStruct * * font_struct ;
char * * font_name ;
int ascent ;
int descent ;
int max_ascent ;
int max_descent ;
int max_width ;
struct font_hdr * ttf ;
} * f , * f1 , * f2 , * f3 , * f4 ;
1999-09-27 15:52:02 -07:00
/* "ARIAL/30" "COMIC/30" "IMPACT/30" "Prole/30" "Proteron/30" */
/* "TIMES/30" "badacid/30" "bajoran/30" "bigfish/30" */
1999-09-28 16:48:39 -07:00
imlib_add_path_to_font_path ( " ./ttfonts " ) ;
2000-12-12 13:07:38 -08:00
if ( xfdtest )
{
printf ( " Font Cache test start \n " ) ;
f = imlib_load_font ( " notepad/10 " ) ;
printf ( " imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
imlib_context_set_font ( ( Imlib_Font ) f ) ;
printf ( " \t \t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d \n " ,
imlib_get_font_ascent ( ) , imlib_get_font_descent ( ) ,
imlib_get_maximum_font_ascent ( ) , imlib_get_maximum_font_descent ( ) ) ;
imlib_free_font ( ) ;
printf ( " imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
printf ( " \n " ) ;
f = imlib_load_font ( " -*-fixed-*--14-* " ) ;
printf ( " imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
imlib_context_set_font ( ( Imlib_Font ) f ) ;
printf ( " \t \t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d \n " ,
imlib_get_font_ascent ( ) , imlib_get_font_descent ( ) ,
imlib_get_maximum_font_ascent ( ) , imlib_get_maximum_font_descent ( ) ) ;
imlib_free_font ( ) ;
printf ( " imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
printf ( " \n " ) ;
f1 = imlib_load_font ( " notepad/10 " ) ;
printf ( " imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f1 , f1 - > next , f1 - > type , f1 - > ref , f1 - > name ) ;
f2 = imlib_load_font ( " -*-fixed-*--14-* " ) ;
printf ( " imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f2 , f2 - > next , f2 - > type , f2 - > ref , f2 - > name ) ;
f3 = imlib_load_font ( " notepad/10,-*-fixed-*--14-* " ) ;
printf ( " imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f3 , f3 - > next , f3 - > type , f3 - > ref , f3 - > name ) ;
f = f3 - > ttf ;
printf ( " f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
f4 = imlib_load_font ( " notepad/10,-*-fixed-*--14-* " ) ;
printf ( " imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f4 , f4 - > next , f4 - > type , f4 - > ref , f4 - > name ) ;
f = f4 - > ttf ;
printf ( " f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
printf ( " \n " ) ;
imlib_context_set_font ( ( Imlib_Font ) f4 ) ;
imlib_free_font ( ) ;
printf ( " imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f4 , f4 - > next , f4 - > type , f4 - > ref , f4 - > name ) ;
f = f4 - > ttf ;
printf ( " f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
imlib_context_set_font ( ( Imlib_Font ) f1 ) ;
imlib_free_font ( ) ;
printf ( " imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f1 , f1 - > next , f1 - > type , f1 - > ref , f1 - > name ) ;
imlib_context_set_font ( ( Imlib_Font ) f2 ) ;
imlib_free_font ( ) ;
printf ( " imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f2 , f2 - > next , f2 - > type , f2 - > ref , f2 - > name ) ;
imlib_context_set_font ( ( Imlib_Font ) f3 ) ;
imlib_free_font ( ) ;
printf ( " imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f3 , f3 - > next , f3 - > type , f3 - > ref , f3 - > name ) ;
f = f3 - > ttf ;
printf ( " f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
printf ( " \n " ) ;
imlib_flush_font_cache ( ) ;
printf ( " imlib_flush_font_cache: \n " ) ;
printf ( " \n " ) ;
f1 = imlib_load_font ( " notepad/10,-*-fixed-*--14-* " ) ;
printf ( " imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f1 , f1 - > next , f1 - > type , f1 - > ref , f1 - > name ) ;
f = f1 - > ttf ;
printf ( " f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s' \n " ,
f , f - > next , f - > type , f - > ref , f - > name ) ;
imlib_context_set_font ( ( Imlib_Font ) f1 ) ;
printf ( " \t \t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d \n " ,
imlib_get_font_ascent ( ) , imlib_get_font_descent ( ) ,
imlib_get_maximum_font_ascent ( ) , imlib_get_maximum_font_descent ( ) ) ;
printf ( " Font Cache test end \n " ) ;
}
1999-09-27 15:52:02 -07:00
if ( fon )
1999-09-27 15:55:56 -07:00
{
1999-09-28 16:48:39 -07:00
fn = imlib_load_font ( fon ) ;
2000-12-12 13:07:38 -08:00
if ( xfdtest )
{
int i ;
f = fn ;
if ( fn ! = NULL & & f - > type & 2 )
for ( i = 0 ; i < f - > font_count ; i + + )
printf ( " xfont%d: %s \n " , i , f - > font_name [ i ] ) ;
}
1999-12-07 10:02:47 -08:00
imlib_context_set_font ( fn ) ;
1999-09-27 15:55:56 -07:00
if ( ! fn )
fon = NULL ;
}
1999-09-26 14:36:51 -07:00
1999-12-07 10:02:47 -08:00
imlib_context_set_progress_function ( NULL ) ;
imlib_context_set_progress_granularity ( 0 ) ;
1999-09-14 18:15:55 -07:00
if ( file )
im_bg = imlib_load_image ( file ) ;
else
im_bg = imlib_load_image ( " test_images/bg.png " ) ;
1999-12-07 10:02:47 -08:00
imlib_context_set_image ( im_bg ) ;
im_tmp = imlib_clone_image ( ) ;
w = imlib_image_get_width ( ) ;
h = imlib_image_get_height ( ) ;
1999-09-18 00:50:37 -07:00
wo = w ;
ho = h ;
1999-09-18 23:28:54 -07:00
w * = 1 ;
h * = 1 ;
1999-09-12 18:56:57 -07:00
XResizeWindow ( disp , win , w , h ) ;
1999-09-26 14:36:51 -07:00
XSync ( disp , False ) ;
1999-09-12 18:56:57 -07:00
im = imlib_create_image ( w , h ) ;
imlib_set_cache_size ( 4 * 1024 * 1024 ) ;
1999-09-26 14:36:51 -07:00
i = 0 ;
up = imlib_update_append_rect ( up , 0 , 0 , w , h ) ;
x = - 9999 ;
y = - 9999 ;
1999-09-08 10:27:40 -07:00
while ( 1 )
{
1999-09-26 14:36:51 -07:00
px = x ;
py = y ;
do
{
XNextEvent ( disp , & ev ) ;
switch ( ev . type )
{
case Expose :
up = imlib_update_append_rect ( up ,
2000-05-05 09:28:39 -07:00
ev . xexpose . x , ev . xexpose . y ,
ev . xexpose . width , ev . xexpose . height ) ;
1999-09-26 14:36:51 -07:00
break ;
1999-09-27 15:52:02 -07:00
case ButtonRelease :
2000-12-12 13:07:38 -08:00
if ( fon )
{
imlib_context_set_font ( fn ) ;
imlib_free_font ( ) ;
}
1999-09-26 14:36:51 -07:00
exit ( 0 ) ;
break ;
case MotionNotify :
x = ev . xmotion . x ;
y = ev . xmotion . y ;
default :
break ;
}
}
while ( XPending ( disp ) ) ;
1999-09-08 10:27:40 -07:00
1999-09-12 18:56:57 -07:00
im_sh1 = imlib_load_image ( " test_images/sh1.png " ) ;
im_sh2 = imlib_load_image ( " test_images/sh2.png " ) ;
im_sh3 = imlib_load_image ( " test_images/sh3.png " ) ;
im_ic [ 0 ] = imlib_load_image ( " test_images/audio.png " ) ;
im_ic [ 1 ] = imlib_load_image ( " test_images/folder.png " ) ;
im_ic [ 2 ] = imlib_load_image ( " test_images/mush.png " ) ;
im_ic [ 3 ] = imlib_load_image ( " test_images/paper.png " ) ;
1999-09-12 22:32:36 -07:00
im_ic [ 4 ] = imlib_load_image ( " test_images/mail.png " ) ;
im_ic [ 5 ] = imlib_load_image ( " test_images/calc.png " ) ;
im_ic [ 6 ] = imlib_load_image ( " test_images/cal.png " ) ;
im_ic [ 7 ] = imlib_load_image ( " test_images/stop.png " ) ;
im_ic [ 8 ] = imlib_load_image ( " test_images/globe.png " ) ;
im_ic [ 9 ] = imlib_load_image ( " test_images/menu.png " ) ;
im_ic [ 10 ] = imlib_load_image ( " test_images/tnt.png " ) ;
im_ic [ 11 ] = imlib_load_image ( " test_images/bulb.png " ) ;
im_ic [ 12 ] = imlib_load_image ( " test_images/lock.png " ) ;
2000-05-05 09:28:39 -07:00
1999-12-07 10:02:47 -08:00
imlib_context_set_image ( im ) ;
1999-09-26 14:36:51 -07:00
if ( first )
1999-09-12 18:56:57 -07:00
{
1999-12-07 10:02:47 -08:00
imlib_blend_image_onto_image ( im_bg , 0 ,
1999-09-26 14:36:51 -07:00
0 , 0 , w , h ,
1999-12-07 10:02:47 -08:00
0 , 0 , w , h ) ;
1999-09-26 14:36:51 -07:00
first = 0 ;
}
2000-02-27 10:36:26 -08:00
else if ( rotate )
{
Imlib_Image rotim ;
2000-03-03 08:42:18 -08:00
double s , c ;
int x1 , y1 , x2 , y2 , w , h ;
2000-03-03 09:24:46 -08:00
2000-03-03 08:42:18 -08:00
w = imlib_image_get_width ( ) ;
h = imlib_image_get_height ( ) ;
s = sin ( 6.2831853 * ( double ) y / ( double ) h ) ;
c = cos ( 6.2831853 * ( double ) y / ( double ) h ) ;
2000-03-03 09:24:46 -08:00
2000-03-03 08:42:18 -08:00
x1 = ( w - w * c + h * s ) / 2 ;
y1 = ( h - h * c - w * s ) / 2 ;
x2 = ( w + w * c - h * s ) / 2 ;
y2 = ( h + h * c + w * s ) / 2 ;
2000-02-27 10:36:26 -08:00
imlib_context_set_blend ( 1 ) ;
2000-03-03 08:42:18 -08:00
imlib_blend_image_onto_image_at_angle ( im_bg , 0 ,
2000-03-03 09:24:46 -08:00
0 , 0 ,
imlib_image_get_width ( ) ,
imlib_image_get_height ( ) ,
x1 , y1 , x2 , y2 ) ;
2000-03-03 08:42:18 -08:00
up = imlib_update_append_rect ( up , 0 , 0 ,
imlib_image_get_width ( ) ,
imlib_image_get_height ( ) ) ;
2000-03-03 09:24:46 -08:00
2000-02-27 10:36:26 -08:00
}
2000-05-30 23:21:52 -07:00
/*
2000-05-21 12:20:53 -07:00
if ( bump_map_to_point )
2000-05-21 20:23:03 -07:00
imlib_apply_filter ( " bump_map_point(x=[],y=[],map=test_images/bulb.png); " , & x , & y ) ;
2000-05-21 12:20:53 -07:00
else
2000-05-21 20:23:03 -07:00
imlib_apply_filter ( " bump_map(x=[],y=[],map=test_images/bulb.png); " , & x , & y ) ;
2000-05-30 23:21:52 -07:00
*/
2000-05-20 15:33:14 -07:00
up = imlib_update_append_rect ( up , 0 , 0 ,
imlib_image_get_width ( ) ,
imlib_image_get_height ( ) ) ;
{
1999-09-30 09:46:04 -07:00
Imlib_Updates uu ;
2000-08-31 15:49:06 -07:00
Commiting what I have so far. More to do tomorrow, but it's 3am.
Polygons are now filled with antialiasing, if context_antialias is set.
So are ellipses.
I fixed some clipping bugs.
There is a bug with the AA span though, it's just a little one, but I'm too
tired to find it now. You will see it if you look closely at the top of the
filled ellipse in test/imlib2, using xmag or something.
I'll fix that tomorrow, speed things up a bit, and hopefully implement AA
drawing for ellipse outlines. Oh, I'll unroll some more loops too.
raster: your last commit broke the two test apps. a segv in _RGBA_init()
somewhere, I know it's not my new code, as I tried a fresh checkout and it
did the same thing. I don't have time to check it out tonight though.
SVN revision: 3498
2000-09-16 18:57:01 -07:00
imlib_context_set_cliprect ( 0 , 0 , 0 , 0 ) ;
1999-12-07 10:02:47 -08:00
imlib_context_set_color ( 255 , 255 , 255 , 255 ) ;
uu = imlib_image_draw_line ( 200 , 200 , x , y , 1 ) ;
2000-08-31 15:49:06 -07:00
up = imlib_updates_append_updates ( up , uu ) ;
/* test ellipses */
imlib_context_set_color ( 255 , 255 , 255 , 255 ) ;
2000-09-03 12:31:03 -07:00
imlib_image_draw_ellipse ( 50 , 250 , 30 , 40 ) ;
imlib_image_fill_ellipse ( 50 , 300 , 30 , 40 ) ;
2000-08-31 15:49:06 -07:00
imlib_image_draw_rectangle ( 120 , 245 , 70 , 70 ) ;
up = imlib_update_append_rect ( up , 120 , 245 , 70 , 70 ) ;
imlib_image_draw_ellipse ( 160 , 280 , 50 , 20 ) ;
imlib_context_set_cliprect ( 120 , 245 , 70 , 70 ) ;
imlib_context_set_color ( 255 , 55 , 55 , 255 ) ;
imlib_image_draw_ellipse ( 160 , 280 , 50 , 20 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
/* test line clipping */
2000-08-30 11:26:49 -07:00
imlib_context_set_cliprect ( 0 , 0 , 0 , 0 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
imlib_image_draw_rectangle ( 50 , 50 , 100 , 100 ) ;
up = imlib_update_append_rect ( up , 50 , 50 , 100 , 100 ) ;
imlib_context_set_color ( 255 , 255 , 255 , 255 ) ;
2000-08-30 11:26:49 -07:00
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
uu = imlib_image_draw_line ( 0 , 0 , 200 , 200 , 1 ) ;
1999-09-30 09:46:04 -07:00
up = imlib_updates_append_updates ( up , uu ) ;
2000-08-30 11:26:49 -07:00
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
uu = imlib_image_draw_line ( 305 , 25 , 20 , 200 , 1 ) ;
up = imlib_updates_append_updates ( up , uu ) ;
2000-08-30 11:26:49 -07:00
uu = imlib_image_draw_line ( 100 , 5 , 100 , 205 , 1 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
up = imlib_updates_append_updates ( up , uu ) ;
2000-08-30 11:26:49 -07:00
uu = imlib_image_draw_line ( 275 , 5 , 20 , 100 , 1 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
up = imlib_updates_append_updates ( up , uu ) ;
2000-08-30 11:26:49 -07:00
imlib_context_set_color ( 255 , 55 , 55 , 255 ) ;
imlib_context_set_cliprect ( 50 , 50 , 100 , 100 ) ;
uu = imlib_image_draw_line ( 0 , 0 , 200 , 200 , 1 ) ;
up = imlib_updates_append_updates ( up , uu ) ;
uu = imlib_image_draw_line ( 305 , 25 , 20 , 200 , 1 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
up = imlib_updates_append_updates ( up , uu ) ;
2000-08-30 11:26:49 -07:00
uu = imlib_image_draw_line ( 100 , 5 , 100 , 205 , 1 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
up = imlib_updates_append_updates ( up , uu ) ;
2000-08-30 11:26:49 -07:00
uu = imlib_image_draw_line ( 275 , 5 , 20 , 100 , 1 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
up = imlib_updates_append_updates ( up , uu ) ;
2000-08-30 11:26:49 -07:00
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
/* test rectangle clipping */
imlib_context_set_color ( 255 , 255 , 255 , 255 ) ;
2000-08-30 11:26:49 -07:00
imlib_context_set_cliprect ( 0 , 0 , 0 , 0 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
imlib_image_draw_rectangle ( 70 , 90 , 20 , 20 ) ;
2000-08-30 11:26:49 -07:00
imlib_image_draw_rectangle ( 115 , 70 , 60 , 30 ) ;
imlib_image_draw_rectangle ( 30 , 120 , 50 , 50 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
imlib_context_set_color ( 255 , 55 , 55 , 255 ) ;
2000-08-30 11:26:49 -07:00
imlib_context_set_cliprect ( 50 , 50 , 100 , 100 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
2000-08-30 11:26:49 -07:00
imlib_image_draw_rectangle ( 70 , 90 , 20 , 20 ) ;
up = imlib_update_append_rect ( up , 70 , 90 , 20 , 20 ) ;
Added rectangle clipping, in the form:
void
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax);
Works well. If you make install then cd test, make, ./imlib2, you'll see the
demo/test of the clipping code.
Next up: draw_polygon and draw_polygon_clipped.
Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image
blending (fun).
SVN revision: 3276
2000-08-30 09:39:44 -07:00
imlib_image_draw_rectangle ( 115 , 70 , 60 , 30 ) ;
up = imlib_update_append_rect ( up , 115 , 70 , 60 , 30 ) ;
imlib_image_draw_rectangle ( 30 , 120 , 50 , 50 ) ;
up = imlib_update_append_rect ( up , 30 , 120 , 50 , 50 ) ;
2000-08-30 12:52:57 -07:00
imlib_context_set_cliprect ( 0 , 0 , 0 , 0 ) ;
Commiting what I have so far. More to do tomorrow, but it's 3am.
Polygons are now filled with antialiasing, if context_antialias is set.
So are ellipses.
I fixed some clipping bugs.
There is a bug with the AA span though, it's just a little one, but I'm too
tired to find it now. You will see it if you look closely at the top of the
filled ellipse in test/imlib2, using xmag or something.
I'll fix that tomorrow, speed things up a bit, and hopefully implement AA
drawing for ellipse outlines. Oh, I'll unroll some more loops too.
raster: your last commit broke the two test apps. a segv in _RGBA_init()
somewhere, I know it's not my new code, as I tried a fresh checkout and it
did the same thing. I don't have time to check it out tonight though.
SVN revision: 3498
2000-09-16 18:57:01 -07:00
2000-08-30 12:52:57 -07:00
/* test polygons */
2000-09-04 08:56:59 -07:00
imlib_context_set_color ( 255 , 0 , 0 , 128 ) ;
2000-09-03 12:14:02 -07:00
imlib_image_fill_polygon ( poly ) ;
2000-09-03 11:04:00 -07:00
imlib_context_set_color ( 255 , 255 , 255 , 255 ) ;
2000-09-03 12:14:02 -07:00
imlib_image_draw_polygon ( poly2 , 0 ) ;
imlib_image_draw_polygon ( poly3 , 1 ) ;
2000-08-30 12:52:57 -07:00
imlib_image_draw_rectangle ( 380 , 260 , 50 , 50 ) ;
imlib_context_set_color ( 255 , 55 , 55 , 255 ) ;
imlib_context_set_cliprect ( 380 , 260 , 50 , 50 ) ;
2000-09-04 08:56:59 -07:00
imlib_image_fill_polygon ( poly3 ) ;
2000-08-30 12:52:57 -07:00
imlib_context_set_cliprect ( 0 , 0 , 0 , 0 ) ;
1999-09-30 09:46:04 -07:00
}
1999-10-25 09:36:24 -07:00
{
1999-12-07 10:02:47 -08:00
static Imlib_Color_Range rg = NULL ;
1999-10-25 09:36:24 -07:00
if ( ! rg )
{
1999-10-27 07:08:28 -07:00
rg = imlib_create_color_range ( ) ;
1999-12-07 10:02:47 -08:00
imlib_context_set_color_range ( rg ) ;
imlib_context_set_color ( 255 , 255 , 255 , 255 ) ;
imlib_add_color_to_color_range ( 0 ) ;
imlib_context_set_color ( 255 , 255 , 160 , 255 ) ;
imlib_add_color_to_color_range ( 1 ) ;
imlib_context_set_color ( 255 , 160 , 120 , 255 ) ;
imlib_add_color_to_color_range ( 1 ) ;
imlib_context_set_color ( 255 , 80 , 100 , 128 ) ;
imlib_add_color_to_color_range ( 1 ) ;
imlib_context_set_color ( 32 , 48 , 80 , 0 ) ;
imlib_add_color_to_color_range ( 1 ) ;
1999-10-25 09:36:24 -07:00
}
1999-12-07 10:02:47 -08:00
imlib_context_set_operation ( IMLIB_OP_RESHADE ) ;
imlib_image_fill_color_range_rectangle ( 60 , 60 , 256 , 256 , ( double ) x ) ;
1999-10-27 10:44:15 -07:00
up = imlib_update_append_rect ( up , 60 , 60 , 256 , 256 ) ;
1999-12-07 10:02:47 -08:00
imlib_context_set_operation ( IMLIB_OP_COPY ) ;
1999-10-25 09:36:24 -07:00
}
2000-12-12 13:07:38 -08:00
if ( xfdcachetest )
1999-09-27 15:52:02 -07:00
{
2000-12-12 13:07:38 -08:00
int l ;
int retw , reth , tx , ty , nx , ny ;
int secs , usecs , sece , usece ;
FILE * f ;
char buf [ 129 ] ;
f = fopen ( xfdfname , " r " ) ;
if ( ! f )
{
printf ( " file %s can not be opened! \n " , file ) ;
exit ( - 1 ) ;
}
tx = ty = 0 ;
imlib_context_set_color ( 255 , 255 , 255 , 255 ) ;
gettimeofday ( & timev , NULL ) ;
secs = ( int ) timev . tv_sec ;
usecs = ( int ) timev . tv_usec ;
l = xfdloop ;
while ( l )
{
fseek ( f , 0 , SEEK_SET ) ;
while ( fgets ( buf , 128 , f ) )
{
if ( buf [ strlen ( buf ) - 1 ] = = ' \n ' )
buf [ strlen ( buf ) - 1 ] = ' \0 ' ;
imlib_text_draw_with_return_metrics ( tx , ty , buf ,
& retw , & reth ,
& nx , & ny ) ;
up = imlib_update_append_rect ( up , tx , ty , retw , reth ) ;
ty + = ny ;
if ( ty > h )
ty = 0 ;
}
l - - ;
}
gettimeofday ( & timev , NULL ) ;
sece = ( int ) timev . tv_sec ;
usece = ( int ) timev . tv_usec ;
{
double t1 , t2 ;
t1 = ( double ) secs + ( ( double ) usecs / 1000000 ) ;
t2 = ( double ) sece + ( ( double ) usece / 1000000 ) ;
sec = t2 - t1 ;
}
printf ( " %3.3f sec \n " , sec ) ;
}
else if ( fon )
{
int retw , reth , tx , ty , nx , ny , cx , cy , cw , ch , cp ;
int cx2 , cy2 , cw2 , ch2 ;
2000-05-05 09:28:39 -07:00
1999-09-27 15:52:02 -07:00
if ( ! str )
str = " This is a test string " ;
2000-12-12 13:07:38 -08:00
tx = ty = 50 ;
1999-09-27 15:52:02 -07:00
for ( i = 0 ; i < 16 ; i + + )
{
int al ;
2000-12-12 13:07:38 -08:00
imlib_context_set_direction ( textdir ) ;
if ( textdir = = IMLIB_TEXT_TO_ANGLE )
{
double an = ( double ) i / 10.0 ;
imlib_context_set_angle ( an ) ;
}
1999-09-28 16:48:39 -07:00
1999-09-27 15:52:02 -07:00
al = ( 15 - i ) * 16 ;
if ( al > 255 )
al = 255 ;
1999-12-07 10:02:47 -08:00
imlib_context_set_color ( 255 , 255 , 255 , al ) ;
2000-12-12 13:07:38 -08:00
imlib_text_draw_with_return_metrics ( tx , ty , str ,
1999-09-28 16:48:39 -07:00
& retw , & reth ,
& nx , & ny ) ;
2000-12-12 13:07:38 -08:00
up = imlib_update_append_rect ( up , tx , ty , retw , reth ) ;
switch ( textdir )
{
case IMLIB_TEXT_TO_RIGHT :
case IMLIB_TEXT_TO_LEFT :
case IMLIB_TEXT_TO_ANGLE :
ty + = ny ;
break ;
case IMLIB_TEXT_TO_DOWN :
case IMLIB_TEXT_TO_UP :
tx + = nx ;
break ;
}
1999-09-27 15:52:02 -07:00
}
1999-12-07 10:02:47 -08:00
cp = imlib_text_get_index_and_location ( str , x - 50 , y - 50 ,
1999-09-29 10:25:52 -07:00
& cx , & cy , & cw , & ch ) ;
if ( cp > = 0 )
2000-12-12 13:07:38 -08:00
{
char tmp [ 16 ] ;
int len ;
len = mblen ( str + cp , MB_CUR_MAX ) ;
if ( len < 0 )
len = 1 ;
strncpy ( tmp , str + cp , len ) ;
tmp [ len ] = ' \0 ' ;
printf ( " over char %s : cp=%d cx=%d cy=%d cw=%d ch=%d : " ,
tmp , cp , cx , cy , cw , ch ) ;
imlib_text_get_location_at_index ( str , cp , & cx2 , & cy2 ,
& cw2 , & ch2 ) ;
printf ( " cx2=%d cy2=%d cw2=%d ch2=%d \n " ,
cx2 , cy2 , cw2 , ch2 ) ;
}
1999-09-27 15:52:02 -07:00
}
1999-12-07 10:02:47 -08:00
imlib_context_set_blend ( 1 ) ;
1999-09-26 14:36:51 -07:00
if ( ( px ! = x ) | | ( py ! = y ) )
{
for ( j = 0 ; j < 32 ; j + + )
1999-09-12 18:56:57 -07:00
{
1999-09-26 14:36:51 -07:00
for ( i = 0 ; i < 32 ; i + + )
{
int ic , iw , ih , ww , hh ;
ic = ( ( j * 32 ) + i ) % 13 ;
1999-12-07 10:02:47 -08:00
imlib_context_set_image ( im_ic [ ic ] ) ;
iw = imlib_image_get_width ( ) ;
ih = imlib_image_get_height ( ) ;
1999-09-26 14:36:51 -07:00
ww = iw ;
hh = ih ;
up = imlib_update_append_rect ( up , x + ( i * iw * 2 ) ,
y + ( j * ih * 2 ) , ww , hh ) ;
up = imlib_update_append_rect ( up , px + ( i * iw * 2 ) ,
py + ( j * ih * 2 ) , ww , hh ) ;
1999-12-07 10:02:47 -08:00
imlib_context_set_image ( im ) ;
imlib_blend_image_onto_image ( im_ic [ ic ] , 0 ,
1999-09-26 14:36:51 -07:00
0 , 0 , iw , ih ,
x + ( i * iw * 2 ) ,
y + ( j * ih * 2 ) ,
1999-12-07 10:02:47 -08:00
ww , hh ) ;
1999-09-26 14:36:51 -07:00
}
1999-09-12 18:56:57 -07:00
}
}
2000-05-30 23:23:40 -07:00
/*
2000-05-20 10:37:00 -07:00
imlib_apply_filter ( " tint(x=200,y=200,w=300,h=100,alpha=100,red=155,green=25,blue=25); " \
" tint(green=20,red=20,blue=20,alpha=200,x=30,y=30); " \
2000-05-21 20:23:03 -07:00
" tint(green=40,red=40,blue=240,alpha=60,x=50,y=150,h=200); " ) ;
2000-05-30 23:23:40 -07:00
*/
1999-12-07 10:02:47 -08:00
imlib_blend_image_onto_image ( im_sh1 , 0 , 0 , 0 , 50 , 50 , 0 , 0 , 50 , 50 ) ;
1999-09-26 14:36:51 -07:00
up = imlib_update_append_rect ( up , 0 , 0 , 50 , 50 ) ;
1999-12-07 10:02:47 -08:00
imlib_blend_image_onto_image ( im_sh2 , 0 , 0 , 0 , 50 , 50 , 50 , 0 , w - 50 , 50 ) ;
1999-09-26 14:36:51 -07:00
up = imlib_update_append_rect ( up , 50 , 0 , w - 50 , 50 ) ;
1999-12-07 10:02:47 -08:00
imlib_blend_image_onto_image ( im_sh3 , 0 , 0 , 0 , 50 , 50 , 0 , 50 , 50 , h - 50 ) ;
1999-09-26 14:36:51 -07:00
up = imlib_update_append_rect ( up , 0 , 50 , 50 , h - 50 ) ;
1999-09-29 10:25:52 -07:00
up = imlib_updates_merge_for_rendering ( up , w , h ) ;
1999-12-07 10:02:47 -08:00
imlib_context_set_blend ( 0 ) ;
imlib_render_image_updates_on_drawable ( up , 0 , 0 ) ;
1999-09-26 14:36:51 -07:00
if ( ( px ! = x ) | | ( py ! = y ) )
{
Imlib_Updates u ;
u = up ;
while ( u )
{
int ux , uy , uw , uh ;
imlib_updates_get_coordinates ( u , & ux , & uy , & uw , & uh ) ;
1999-12-07 10:02:47 -08:00
imlib_blend_image_onto_image ( im_bg , 0 ,
1999-09-26 14:36:51 -07:00
ux , uy , uw , uh ,
1999-12-07 10:02:47 -08:00
ux , uy , uw , uh ) ;
1999-09-26 14:36:51 -07:00
u = imlib_updates_get_next ( u ) ;
}
}
imlib_updates_free ( up ) ;
up = NULL ;
1999-12-07 10:02:47 -08:00
imlib_context_set_image ( im_sh1 ) ; imlib_free_image ( ) ;
imlib_context_set_image ( im_sh1 ) ; imlib_free_image ( ) ;
imlib_context_set_image ( im_sh1 ) ; imlib_free_image ( ) ;
imlib_context_set_image ( im_ic [ 0 ] ) ; imlib_free_image ( ) ;
imlib_context_set_image ( im_ic [ 1 ] ) ; imlib_free_image ( ) ;
imlib_context_set_image ( im_ic [ 2 ] ) ; imlib_free_image ( ) ;
imlib_context_set_image ( im_ic [ 3 ] ) ; imlib_free_image ( ) ;
2000-05-05 09:28:39 -07:00
1999-09-08 10:27:40 -07:00
}
}
1999-08-01 15:14:11 -07:00
else
{
2000-09-11 22:46:17 -07:00
printf ( " blast test \n " ) ;
2000-03-03 08:42:18 -08:00
pixels = 0 ;
2000-05-05 09:28:39 -07:00
imlib_context_set_color_modifier ( colormod ) ;
1999-09-08 10:27:40 -07:00
for ( i = 0 ; i < w ; i + + )
{
1999-12-07 10:02:47 -08:00
imlib_render_image_on_drawable_at_size ( 0 , 0 , w , h ) ;
1999-09-08 10:27:40 -07:00
pixels + = w * h ;
}
1999-08-01 15:14:11 -07:00
}
2000-05-05 09:28:39 -07:00
2000-04-28 10:42:49 -07:00
/**
* Determine horse power of your video card driver
*/
1999-08-01 15:14:11 -07:00
gettimeofday ( & timev , NULL ) ;
sec2 = ( int ) timev . tv_sec ; /* and stores it so we can time outselves */
usec2 = ( int ) timev . tv_usec ; /* we will use this to vary speed of rot */
printf ( " done \n " ) ;
{
2000-03-28 14:25:45 -08:00
double t1 , t2 ;
t1 = ( double ) sec1 + ( ( double ) usec1 / 1000000 ) ;
t2 = ( double ) sec2 + ( ( double ) usec2 / 1000000 ) ;
sec = t2 - t1 ;
1999-08-01 15:14:11 -07:00
}
2000-03-03 08:42:18 -08:00
printf ( " %3.3f sec, %3.3f M pixels (%i) \n " , sec , ( double ) pixels / 1000000 , pixels ) ;
1999-08-01 15:14:11 -07:00
printf ( " %3.3f Mpixels / sec \n " , ( double ) ( pixels ) / ( sec * 1000000 ) ) ;
return 0 ;
}