5 #include <glib/gi18n.h>
10 #define DOODLE_DIR DATA_DIR "/doodle/"
17 image = malloc (sizeof(PIXImage));
18 image->data = malloc(sizeof(char)*255);
19 image->free = tbo_pix_image_free;
20 image->draw = tbo_pix_image_draw;
21 image->save = tbo_pix_image_save;
22 image->clone = tbo_pix_image_clone;
30 tbo_piximage_new_width_params (int x,
37 image = tbo_piximage_new ();
41 image->height = height;
42 snprintf (image->data, 255, "%s", path);
50 tbo_pix_image_free (PIXImage *self)
57 tbo_pix_image_draw (PIXImage *self, Frame *frame, cairo_t *cr)
60 cairo_surface_t *image;
62 image = cairo_image_surface_create_from_png (self->data);
63 w = cairo_image_surface_get_width (image);
64 h = cairo_image_surface_get_height (image);
66 if (!self->width) self->width = w;
67 if (!self->height) self->height = h;
69 float factorw = (float)self->width / (float)w;
70 float factorh = (float)self->height / (float)h;
72 cairo_matrix_t mx = {1, 0, 0, 1, 0, 0};
73 tbo_object_get_flip_matrix (self, &mx);
75 cairo_rectangle(cr, frame->x+2, frame->y+2, frame->width-4, frame->height-4);
77 cairo_translate (cr, frame->x+self->x, frame->y+self->y);
78 cairo_rotate (cr, self->angle);
79 cairo_transform (cr, &mx);
80 cairo_scale (cr, factorw, factorh);
82 cairo_set_source_surface (cr, image, 0, 0);
85 cairo_scale (cr, 1/factorw, 1/factorh);
86 cairo_transform (cr, &mx);
87 cairo_rotate (cr, -self->angle);
88 cairo_translate (cr, -(frame->x+self->x), -(frame->y+self->y));
89 cairo_reset_clip (cr);
92 cairo_surface_destroy (image);
96 tbo_pix_image_save (PIXImage *self, FILE *file)
100 snprintf (buffer, 1024, " <piximage x=\"%d\" y=\"%d\" "
101 "width=\"%d\" height=\"%d\" "
102 "angle=\"%f\" flipv=\"%d\" fliph=\"%d\" "
104 self->x, self->y, self->width, self->height,
105 self->angle, self->flipv, self->fliph, (char*)self->data);
106 fwrite (buffer, sizeof (char), strlen (buffer), file);
108 snprintf (buffer, 1024, " </piximage>\n");
109 fwrite (buffer, sizeof (char), strlen (buffer), file);
113 tbo_pix_image_clone (PIXImage *self)
117 newimage = tbo_piximage_new_width_params (self->x,
122 newimage->angle = self->angle;
123 newimage->flipv = self->flipv;
124 newimage->fliph = self->fliph;