… | |
… | |
5 | #if HAVE_IMG |
5 | #if HAVE_IMG |
6 | |
6 | |
7 | #define float_to_component(d) ((d) * 65535.99) |
7 | #define float_to_component(d) ((d) * 65535.99) |
8 | |
8 | |
9 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) |
9 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) |
10 | : s(screen), w(width), h(height), format(format), shared(false) |
10 | : s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal), shared(false) |
11 | { |
11 | { |
12 | pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth); |
12 | pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth); |
13 | } |
13 | } |
14 | |
14 | |
15 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) |
15 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) |
16 | : s(screen), pm(pixmap), w(width), h(height), format(format), shared(false) |
16 | : s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal), shared(false), pm(pixmap) |
17 | { |
17 | { |
18 | } |
18 | } |
19 | |
19 | |
20 | rxvt_img * |
20 | rxvt_img * |
21 | rxvt_img::new_from_root (rxvt_screen *s) |
21 | rxvt_img::new_from_root (rxvt_screen *s) |
… | |
… | |
352 | |
352 | |
353 | return img; |
353 | return img; |
354 | } |
354 | } |
355 | |
355 | |
356 | rxvt_img * |
356 | rxvt_img * |
357 | rxvt_img::sub_rect (int x, int y, int width, int height, int repeat) |
357 | rxvt_img::sub_rect (int x, int y, int width, int height) |
358 | { |
358 | { |
359 | rxvt_img *img = new rxvt_img (s, format, width, height); |
359 | rxvt_img *img = new rxvt_img (s, format, width, height); |
360 | |
360 | |
361 | Display *dpy = s->display->dpy; |
361 | Display *dpy = s->display->dpy; |
362 | XRenderPictureAttributes pa; |
362 | XRenderPictureAttributes pa; |
… | |
… | |
371 | |
371 | |
372 | return img; |
372 | return img; |
373 | } |
373 | } |
374 | |
374 | |
375 | rxvt_img * |
375 | rxvt_img * |
376 | rxvt_img::transform (int new_width, int new_height, double matrix[9], int repeat) |
376 | rxvt_img::transform (int new_width, int new_height, double matrix[9]) |
377 | { |
377 | { |
378 | rxvt_img *img = new rxvt_img (s, format, new_width, new_height); |
378 | rxvt_img *img = new rxvt_img (s, format, new_width, new_height); |
379 | |
379 | |
380 | Display *dpy = s->display->dpy; |
380 | Display *dpy = s->display->dpy; |
381 | XRenderPictureAttributes pa; |
381 | XRenderPictureAttributes pa; |
… | |
… | |
410 | |
410 | |
411 | return transform (new_width, new_height, matrix); |
411 | return transform (new_width, new_height, matrix); |
412 | } |
412 | } |
413 | |
413 | |
414 | rxvt_img * |
414 | rxvt_img * |
415 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi, int repeat) |
415 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi) |
416 | { |
416 | { |
417 | double s = sin (phi); |
417 | double s = sin (phi); |
418 | double c = cos (phi); |
418 | double c = cos (phi); |
419 | |
419 | |
420 | double matrix[9] = { |
420 | double matrix[9] = { |
421 | c, -s, -c * x + s * y + x, |
421 | c, -s, -c * x + s * y + x, |
422 | s, c, -s * x - c * y + y, |
422 | s, c, -s * x - c * y + y, |
423 | 0, 0, 1 |
423 | 0, 0, 1 |
424 | }; |
424 | }; |
425 | |
425 | |
426 | return transform (new_width, new_height, matrix, repeat); |
426 | return transform (new_width, new_height, matrix); |
427 | } |
427 | } |
428 | |
428 | |
429 | rxvt_img * |
429 | rxvt_img * |
430 | rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg) |
430 | rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg) |
431 | { |
431 | { |