32 return CAIRO_STATUS_SUCCESS;
37 png_stream.
data = name;
39 return cairo_image_surface_create_from_png_stream(&
png_stream_reader, (
void *)&png_stream);
43 int width = cairo_image_surface_get_width(getpng);
44 int height = cairo_image_surface_get_height(getpng);
45 cairo_surface_destroy(w->
image);
49 CAIRO_CONTENT_COLOR_ALPHA, width, height);
50 cairo_t *cri = cairo_create (w->
image);
51 cairo_set_source_surface (cri, getpng,0,0);
57 int width = cairo_image_surface_get_width(getpng);
58 int height = cairo_image_surface_get_height(getpng);
61 double x = (double)width_t/(
double)width;
62 double y = (double)height_t/(
double)height;
63 cairo_surface_destroy(w->
image);
67 CAIRO_CONTENT_COLOR_ALPHA, width_t, height_t);
68 cairo_t *cri = cairo_create (w->
image);
69 cairo_scale(cri, x,y);
70 cairo_set_source_surface (cri, getpng,0,0);
78 cairo_surface_destroy(getpng);
84 cairo_surface_destroy(getpng);
88 cairo_surface_t *getpng = cairo_image_surface_create_from_png (filename);
90 cairo_surface_destroy(getpng);
94 cairo_surface_t *getpng = cairo_image_surface_create_from_png (filename);
96 cairo_surface_destroy(getpng);
106 int width = cairo_image_surface_get_width(getpng);
107 int height = cairo_image_surface_get_height(getpng);
109 sf = cairo_surface_create_similar (w->
surface,
110 CAIRO_CONTENT_COLOR_ALPHA, width, height);
111 cairo_t *cri = cairo_create (sf);
112 cairo_set_source_surface (cri, getpng,0,0);
114 cairo_surface_destroy(getpng);
123 int width_t = cairo_xlib_surface_get_width(image);
124 int height_t = cairo_xlib_surface_get_height(image);
125 cairo_surface_t *icon = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width_t, height_t);
126 cairo_t *cri = cairo_create (icon);
127 cairo_set_source_surface (cri, image,0,0);
130 int stride = cairo_image_surface_get_stride (icon);
131 unsigned long* icon_data = malloc(2+width_t*height_t *
sizeof(
unsigned long));
132 memset(icon_data, 0, 2+width_t*height_t *
sizeof(
unsigned long));
133 const unsigned char *data = cairo_image_surface_get_data(icon);
134 icon_data[0] = width_t;
135 icon_data[1] = height_t;
138 unsigned long* output_pixel = icon_data;
140 for (y = 0; y < height_t; y++) {
141 uint32_t *row = (uint32_t*) (data + y * stride);
142 for (x = 0; x < width_t; x++) {
143 output_pixel[0] |= row[x];
148 Atom net_wm_icon = XInternAtom(w->
app->
dpy,
"_NET_WM_ICON", False);
149 Atom cardinal = XInternAtom(w->
app->
dpy,
"CARDINAL", False);
150 XChangeProperty(w->
app->
dpy, w->
widget, net_wm_icon, cardinal, 32, PropModeReplace,
151 (
const unsigned char*) icon_data, 2+width_t*height_t);
153 cairo_surface_destroy(icon);
164 int width_t = cairo_image_surface_get_width(image);
165 int height_t = cairo_image_surface_get_height(image);
166 int stride = cairo_image_surface_get_stride (image);
167 unsigned long* icon_data = malloc(16+width_t*height_t *
sizeof(
unsigned long));
168 memset(icon_data, 0, 16+width_t*height_t *
sizeof(
unsigned long));
169 const unsigned char *data = cairo_image_surface_get_data(image);
170 icon_data[0] = width_t;
171 icon_data[1] = height_t;
174 unsigned long* output_pixel = icon_data;
176 for (y = 0; y < height_t; y++) {
177 uint32_t *row = (uint32_t*) (data + y * stride);
178 for (x = 0; x < width_t; x++) {
179 output_pixel[0] |= row[x];
184 Atom net_wm_icon = XInternAtom(w->
app->
dpy,
"_NET_WM_ICON", False);
185 Atom cardinal = XInternAtom(w->
app->
dpy,
"CARDINAL", False);
186 XChangeProperty(w->
app->
dpy, w->
widget, net_wm_icon, cardinal, 32, PropModeReplace,
187 (
const unsigned char*) icon_data, 2+width_t*height_t);
189 cairo_surface_destroy(image);
binary_stream - struct definition to read binary data into cairo surface
const unsigned char * data
void widget_get_png_from_file(Widget_t *w, const char *filename)
widget_get_png_from_file - read png from file into Widget_t xlib surface
void _copy_surface_to_widget(Widget_t *w, cairo_surface_t *getpng)
cairo_status_t png_stream_reader(void *_stream, unsigned char *data, unsigned int length)
void widget_get_scaled_png_from_file(Widget_t *w, const char *filename)
widget_get_scaled_png_from_file - read scaled png into Widget_t xlib surface
void widget_get_scaled_png(Widget_t *w, const unsigned char *name)
widget_get_scaled_png - read scaled png into Widget_t xlib surface
void widget_get_png(Widget_t *w, const unsigned char *name)
widget_get_png - read png into Widget_t xlib surface
cairo_surface_t * surface_get_png(Widget_t *w, cairo_surface_t *sf, const unsigned char *name)
surface_get_png - read png into Widget_t xlib surface
void _copy_scaled_surface_to_widget(Widget_t *w, cairo_surface_t *getpng)
void widget_set_icon_from_png(Widget_t *w, const unsigned char *name)
widget_set_icon_from_png - set icon image from png binary to Widget_t those icon will be used in the ...
void widget_set_icon_from_surface(Widget_t *w, cairo_surface_t *image)
widget_set_icon_from_surface - set icon image from cairo surface for Widget_t those icon will be used...
cairo_surface_t * cairo_image_surface_create_from_stream(const unsigned char *name)
cairo_image_surface_create_from_stream - read binary data into cairo surface from stream
void widget_get_surface_ptr(Widget_t *w, Widget_t *wid)
widget_get_surface_ptr - set pointer to a 2. Widget_t xlib surface