/* Create and initalize global sticky notes instance */ void stickynotes_applet_init (PanelApplet *panel_applet) { stickynotes = g_new(StickyNotes, 1); stickynotes->notes = NULL; stickynotes->applets = NULL; stickynotes->last_timeout_data = 0; g_set_application_name (_("Sticky Notes")); /* Register size for icons */ gtk_icon_size_register ("stickynotes_icon_size", 8,8); gtk_window_set_default_icon_name ("consort-sticky-notes-applet"); stickynotes->icon_normal = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default (), "consort-sticky-notes-applet", 48, 0, NULL); stickynotes->icon_prelight = gdk_pixbuf_new ( gdk_pixbuf_get_colorspace (stickynotes->icon_normal), gdk_pixbuf_get_has_alpha (stickynotes->icon_normal), gdk_pixbuf_get_bits_per_sample ( stickynotes->icon_normal), gdk_pixbuf_get_width (stickynotes->icon_normal), gdk_pixbuf_get_height (stickynotes->icon_normal)); stickynotes_make_prelight_icon (stickynotes->icon_prelight, stickynotes->icon_normal, 30); stickynotes->gconf = gconf_client_get_default(); stickynotes->visible = TRUE; stickynotes_applet_init_icons(); stickynotes_applet_init_prefs(); /* Watch GConf values */ gconf_client_add_dir (stickynotes->gconf, GCONF_PATH, GCONF_CLIENT_PRELOAD_NONE, NULL); gconf_client_notify_add (stickynotes->gconf, GCONF_PATH "/defaults", (GConfClientNotifyFunc) preferences_apply_cb, NULL, NULL, NULL); gconf_client_notify_add (stickynotes->gconf, GCONF_PATH "/settings", (GConfClientNotifyFunc) preferences_apply_cb, NULL, NULL, NULL); /* Max height for large notes*/ stickynotes->max_height = 0.8*gdk_screen_get_height( gdk_screen_get_default() ); /* Load sticky notes */ stickynotes_load (gtk_widget_get_screen (GTK_WIDGET (panel_applet))); install_check_click_on_desktop (); }
static void draw (QCADDesignObject *obj, GdkDrawable *dst, GdkFunction rop, GdkRectangle *rcClip) { int Nix, Nix1 ; QCADClockingLayer *clocking_layer = QCAD_CLOCKING_LAYER (obj) ; QCADLayer *layer = QCAD_LAYER (obj) ; GdkGC *gc = NULL ; double potential ; GList *llItr = NULL ; double x, y; QCAD_DESIGN_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_CLOCKING_LAYER)))->draw (obj, dst, rop, rcClip) ; gc = gdk_gc_new (dst) ; gdk_gc_set_foreground (gc, clr_idx_to_clr_struct (RED)) ; gdk_gc_set_background (gc, clr_idx_to_clr_struct (RED)) ; gdk_gc_set_clip_rectangle (gc, rcClip) ; if (NULL != layer->lstObjs && clocking_layer->bDrawPotential) { GdkPixbuf *pb = NULL ; pb = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, clocking_layer->tile_size, clocking_layer->tile_size) ; for (Nix = 0; Nix < Nx; Nix++) { x = xmin+dx*Nix; for (Nix1 = 0; Nix1 < Ny; Nix1++) { y = ymin+dy*Nix1; potential = get_potential (x, y, clocking_layer->z_to_draw, Nx, Ny, Nz, dx, dy, dz, xmin, ymin) ; /* if (fabs (potential) < clocking_layer->dExtremePotential / 100.0) { fprintf (stderr, "Potential too small - breaking out\n") ; // continue ; } */ gdk_pixbuf_fill (pb, ((potential > 0) ? 0xFF000000 : 0x0000FF00) | (((int)((fabs (potential) / clocking_layer->dExtremePotential) * 128.0)) & 0xFF)) ; // fprintf (stderr, "opacity = %lf/%lf * 255\n", potential, clocking_layer->dExtremePotential) ; gdk_draw_pixbuf (dst, gc, pb, 0, 0, Nix * clocking_layer->tile_size, Nix1 * clocking_layer->tile_size, clocking_layer->tile_size, clocking_layer->tile_size, GDK_RGB_DITHER_NONE, 0, 0) ; //gdk_draw_pixbuf (dst, gc, pb, 0, 0, Nix * clocking_layer->tile_size, Nix1 * clocking_layer->tile_size, clocking_layer->tile_size, clocking_layer->tile_size, GDK_RGB_DITHER_NONE, 0, 0) ; // gdk_draw_rectangle (dst, gc, TRUE, // Nix * clocking_layer->tile_size + (clocking_layer->tile_size >> 1) - 2, // Nix1 * clocking_layer->tile_size + (clocking_layer->tile_size >> 1) - 2, // 5, 5) ; } } g_object_unref (pb) ; } g_object_unref (gc) ; }
void picture_start(gint w, gint h, gboolean color) { GtkWidget *widget; picture_stop(); picture = g_new0(Picture, 1); picture->width = w; picture->height = h; picture->color = color; picture->x = 0; picture->y = 0; picture->rgb = 0; picture->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, w, h); picture->rowstride = gdk_pixbuf_get_rowstride(picture->pixbuf); gdk_pixbuf_fill(picture->pixbuf, 0xaaaaaaff); if (TRUE) { picture->window = create_picwindow(); picture->image = gtk_image_new_from_pixbuf(picture->pixbuf); widget = lookup_widget(picture->window, "pictureframe"); gtk_container_add(GTK_CONTAINER(widget), picture->image); gtk_widget_show_all(picture->window); g_signal_connect((gpointer) picture->window, "delete_event", G_CALLBACK(delete_callback), (gpointer) picture); widget = lookup_widget(picture->window, "picturesavebutton"); g_signal_connect((gpointer) widget, "clicked", G_CALLBACK(on_picturesavebutton_clicked), (gpointer) picture); widget = lookup_widget(picture->window, "pictureclosebutton"); g_signal_connect((gpointer) widget, "clicked", G_CALLBACK(on_pictureclosebutton_clicked), (gpointer) picture); } else { textview_insert_pixbuf("rxtext", picture->pixbuf); } picture->active = TRUE; }
static cairo_surface_t * get_content_loading_icon (BgSource *source) { GtkIconTheme *theme; GtkIconInfo *icon_info; GdkPixbuf *pixbuf, *ret; GError *error = NULL; int scale_factor; cairo_surface_t *surface; int thumbnail_height; int thumbnail_width; theme = gtk_icon_theme_get_default (); icon_info = gtk_icon_theme_lookup_icon (theme, "content-loading-symbolic", 16, GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK); if (icon_info == NULL) { g_warning ("Failed to find placeholder icon"); return NULL; } pixbuf = gtk_icon_info_load_icon (icon_info, &error); if (pixbuf == NULL) { g_warning ("Failed to load placeholder icon: %s", error->message); g_clear_error (&error); g_clear_object (&icon_info); return NULL; } thumbnail_height = bg_source_get_thumbnail_height (source); thumbnail_width = bg_source_get_thumbnail_width (source); ret = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, thumbnail_width, thumbnail_height); gdk_pixbuf_fill (ret, 0x00000000); /* Put the icon in the middle */ gdk_pixbuf_copy_area (pixbuf, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), ret, (thumbnail_width - gdk_pixbuf_get_width (pixbuf)) / 2, (thumbnail_height - gdk_pixbuf_get_height (pixbuf)) / 2); g_object_unref (pixbuf); scale_factor = bg_source_get_scale_factor (source); surface = gdk_cairo_surface_create_from_pixbuf (ret, scale_factor, NULL); g_object_unref (ret); g_clear_object (&icon_info); return surface; }
/* * Returns a copy of pixbuf src rotated 90 degrees clockwise or 90 counterclockwise */ void rotate90(GdkPixbuf *dest, const GdkPixbuf *src, int sw, int sh, bool counter_clockwise) { gint has_alpha; //gint sw, sh, srs; gint srs; gint drs; guchar *s_pix; guchar *d_pix; gint i, j; gint a; //GdkPixbuf *buffer; guchar *b_pix; gint brs; gint w, h; if (src == 0) return; //sw = gdk_pixbuf_get_width(src); //sh = gdk_pixbuf_get_height(src); has_alpha = gdk_pixbuf_get_has_alpha(src); srs = gdk_pixbuf_get_rowstride(src); s_pix = gdk_pixbuf_get_pixels(src); drs = gdk_pixbuf_get_rowstride(dest); d_pix = gdk_pixbuf_get_pixels(dest); a = has_alpha ? 4 : 3; if (buffer == 0) { buffer = gdk_pixbuf_new(GDK_COLORSPACE_RGB, has_alpha, 8, ROTATE_BUFFER_WIDTH, ROTATE_BUFFER_HEIGHT); } b_pix = gdk_pixbuf_get_pixels(buffer); brs = gdk_pixbuf_get_rowstride(buffer); for (i = 0; i < sh; i+= ROTATE_BUFFER_WIDTH) { w = MIN(ROTATE_BUFFER_WIDTH, sh - i); for (j = 0; j < sw; j += ROTATE_BUFFER_HEIGHT) { gint x, y; h = MIN(ROTATE_BUFFER_HEIGHT, sw - j); pixbuf_copy_block_rotate(s_pix, srs, j, i, b_pix, brs, h, w, a, counter_clockwise); if (counter_clockwise) { x = i; y = sw - h - j; } else { x = sh - w - i; y = j; } pixbuf_copy_block(b_pix, brs, w, h, d_pix, drs, x, y, a); } } }
gint render_camera(gpointer data) { GdkPixbuf *pixbuf = NULL; GdkPixbuf *blobbuf= NULL; GdkGC *gc = NULL; GtkWidget *drawing_area = GTK_WIDGET(data); uint16_t i; gc = GTK_WIDGET(drawing_area)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(drawing_area))]; player_update(); if (g_blob_count > 0) { // Draw the blobs blobbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 1, 1); for (i=0; i< g_blob_count; ++i) { // shift the color by 8-bits to account for the alpha channel gdk_pixbuf_fill(blobbuf, g_blobs[i].color << 8); gdk_pixbuf_composite(blobbuf, g_pixbuf, g_blobs[i].left, g_blobs[i].top, abs(g_blobs[i].right - g_blobs[i].left), abs(g_blobs[i].top - g_blobs[i].bottom), 1, 1, 1, 1, GDK_INTERP_NEAREST, 128); } gdk_pixbuf_unref(blobbuf); } // scale everything at the end if ((g_width==g_window_width)&&(g_height==g_window_height)) { // we don't need to worry about scaling gdk_draw_pixbuf(GTK_WIDGET(drawing_area)->window, gc, g_pixbuf, 0, 0, 0, 0, g_width, g_height, GDK_RGB_DITHER_NONE, 0, 0); } else { pixbuf = gdk_pixbuf_scale_simple(g_pixbuf, g_window_width, g_window_height, GDK_INTERP_BILINEAR); gdk_draw_pixbuf(GTK_WIDGET(drawing_area)->window, gc, pixbuf, 0, 0, 0, 0, g_window_width, g_window_height, GDK_RGB_DITHER_NONE, 0, 0); gdk_pixbuf_unref(pixbuf); } return TRUE; }
/* Started from from http://www.gtkforums.com/about5204.html * Author: tadeboro */ GdkPixbuf * _gdk_pixbuf_new_from_cairo_surface (cairo_surface_t *surface) { int width; int height; int s_stride; unsigned char *s_pixels; GdkPixbuf *pixbuf; int p_stride; guchar *p_pixels; int p_n_channels; if (surface == NULL) return NULL; if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) return NULL; width = cairo_image_surface_get_width (surface); height = cairo_image_surface_get_height (surface); s_stride = cairo_image_surface_get_stride (surface); s_pixels = _cairo_image_surface_flush_and_get_data (surface); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, _cairo_image_surface_get_has_alpha (surface), 8, width, height); p_stride = gdk_pixbuf_get_rowstride (pixbuf); p_pixels = gdk_pixbuf_get_pixels (pixbuf); p_n_channels = gdk_pixbuf_get_n_channels (pixbuf); while (height--) { guchar *s_iter = s_pixels; guchar *p_iter = p_pixels; int i; for (i = 0; i < width; i++) { gdouble alpha_factor = (gdouble) 0xff / s_iter[CAIRO_ALPHA]; p_iter[0] = (guchar) (alpha_factor * s_iter[CAIRO_RED] + .5); p_iter[1] = (guchar) (alpha_factor * s_iter[CAIRO_GREEN] + .5); p_iter[2] = (guchar) (alpha_factor * s_iter[CAIRO_BLUE] + .5); if (p_n_channels == 4) p_iter[3] = s_iter[CAIRO_ALPHA]; s_iter += 4; p_iter += p_n_channels; } s_pixels += s_stride; p_pixels += p_stride; } return pixbuf; }
GdkPixbuf* BitmapImage::getGdkPixbuf() { int width = cairo_image_surface_get_width(frameAtIndex(currentFrame())); int height = cairo_image_surface_get_height(frameAtIndex(currentFrame())); unsigned char* surfaceData = cairo_image_surface_get_data(frameAtIndex(currentFrame())); int surfaceRowStride = cairo_image_surface_get_stride(frameAtIndex(currentFrame())); GdkPixbuf* dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); if (!dest) return 0; guchar* pixbufData = gdk_pixbuf_get_pixels(dest); int pixbufRowStride = gdk_pixbuf_get_rowstride(dest); /* From: http://cairographics.org/manual/cairo-image-surface.html#cairo-format-t * "CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with alpha in * the upper 8 bits, then red, then green, then blue. The 32-bit * quantities are stored native-endian. Pre-multiplied alpha is used. * (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)" * * See http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf * for information on the structure of GdkPixbufs stored with GDK_COLORSPACE_RGB. * * RGB color channels in CAIRO_FORMAT_ARGB32 are stored based on the * endianness of the machine and are also multiplied by the alpha channel. * To properly transfer the data from the Cairo surface we must divide each * of the RGB channels by the alpha channel and then reorder all channels * if this machine is little-endian. */ for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { unsigned char* source = getCairoSurfacePixel(surfaceData, x, y, surfaceRowStride); guchar* dest = getGdkPixbufPixel(pixbufData, x, y, pixbufRowStride); #if G_BYTE_ORDER == G_LITTLE_ENDIAN guchar alpha = source[3]; dest[0] = alpha ? ((source[2] * 255) / alpha) : 0; dest[1] = alpha ? ((source[1] * 255) / alpha) : 0; dest[2] = alpha ? ((source[0] * 255) / alpha) : 0; dest[3] = alpha; #else guchar alpha = source[0]; dest[0] = alpha ? ((source[1] * 255) / alpha) : 0; dest[1] = alpha ? ((source[2] * 255) / alpha) : 0; dest[2] = alpha ? ((source[3] * 255) / alpha) : 0; dest[3] = alpha; #endif } } return dest; }
Pixbuf::Pixbuf() { _width = 500; _height = 500; _ref = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, _width, _height); gdk_pixbuf_fill(_ref, 0xffffffff ); _scale = 1; n_channels = gdk_pixbuf_get_n_channels(_ref); rowstride = gdk_pixbuf_get_rowstride(_ref); pixels = gdk_pixbuf_get_pixels(_ref); };
static GdkPixbuf * renderer_create_empty_background( MMB_Screen *screen ) { GdkPixbuf *pb = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, screen->base.w, screen->base.h ); if ( pb == NULL ) { fprintf( stderr, "Failed to create background pixmap\n" ); exit( EXIT_FAILURE ); } // Make the wallpaper black. gdk_pixbuf_fill( pb, 0x000000FF ); return pb; }
static void gcm_cell_renderer_set_color (GcmCellRendererColor *renderer) { CdColorRGB8 rgb; GdkPixbuf *pixbuf = NULL; gint height = 26; /* TODO: needs to be a property */ gint width = 400; /* TODO: needs to be a property */ gint x, y; guchar *pixels; guint pos; cmsHPROFILE profile_srgb = NULL; cmsHPROFILE profile_lab = NULL; cmsHTRANSFORM xform = NULL; /* nothing set yet */ if (renderer->color == NULL) goto out; /* convert the color to sRGB */ profile_lab = cmsCreateLab2Profile (NULL); profile_srgb = cmsCreate_sRGBProfile (); xform = cmsCreateTransform (profile_lab, TYPE_Lab_DBL, profile_srgb, TYPE_RGB_8, INTENT_ABSOLUTE_COLORIMETRIC, 0); cmsDoTransform (xform, renderer->color, &rgb, 1); /* create a pixbuf of the right size */ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); pixels = gdk_pixbuf_get_pixels (pixbuf); for (y=0; y<height; y++) { for (x=0; x<width; x++) { pos = (y*width+x) * 3; pixels[pos+0] = rgb.R; pixels[pos+1] = rgb.G; pixels[pos+2] = rgb.B; } } out: g_object_set (renderer, "pixbuf", pixbuf, NULL); if (profile_srgb != NULL) cmsCloseProfile (profile_srgb); if (profile_lab != NULL) cmsCloseProfile (profile_lab); if (xform != NULL) cmsDeleteTransform (xform); if (pixbuf != NULL) g_object_unref (pixbuf); }
static GdkPixbuf* plank_drawing_drawing_service_get_empty_pixbuf (gint width, gint height) { GdkPixbuf* result = NULL; GdkPixbuf* pbuf = NULL; gint _tmp0_ = 0; gint _tmp1_ = 0; GdkPixbuf* _tmp2_ = NULL; _tmp0_ = width; _tmp1_ = height; _tmp2_ = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, _tmp0_, _tmp1_); pbuf = _tmp2_; gdk_pixbuf_fill (pbuf, (guint32) 0x00000000); result = pbuf; return result; }
/*! * \brief Draw an image to Dia's _Image * \todo use maskColors to have some alpha support */ void DiaOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, int *maskColors, GBool inlineImg) { DiaObject *obj; GdkPixbuf *pixbuf; Point pos; ObjectChange *change; double *ctm = state->getCTM(); pos.x = ctm[4] * scale; // there is some undocumented magic done with the ctm for drawImage // deduced from SplashOutputDev::drawImage() // cmt[2] and ctm[3] being negative - use that for y postion // ctm[0] and ctm[3] have width and height in device coordinates pos.y = (ctm[5] + ctm[3]) * scale; pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, maskColors ? TRUE : FALSE, 8, width, height); { // 3 channels, 8 bit ImageStream imgStr(str, width, colorMap->getNumPixelComps(), colorMap->getBits()); Guchar *line; int rowstride = gdk_pixbuf_get_rowstride (pixbuf); guchar *pixels = gdk_pixbuf_get_pixels (pixbuf); int y; imgStr.reset(); // otherwise getLine() is crashing right away line = imgStr.getLine (); for (y = 0; y < height && line; ++y) { guchar *dest = pixels + y * rowstride; colorMap->getRGBLine (line, dest, width); // ToDo: respect maskColors line = imgStr.getLine (); } } obj = create_standard_image (pos.x, pos.y, ctm[0] * scale, ctm[3] * scale, NULL); if ((change = dia_object_set_pixbuf (obj, pixbuf)) != NULL) change->free (change); /* reference transfered */ else g_object_unref (pixbuf); addObject (obj); }
/** * gdk_pixbuf_draw_cache_new: * @returns: a new #GdkPixbufDrawCache * * Creates a new pixbuf draw cache. **/ GdkPixbufDrawCache* gdk_pixbuf_draw_cache_new () { GdkPixbufDrawCache *cache = g_new0 (GdkPixbufDrawCache, 1); cache->last_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 1, 1); cache->check_size = 16; cache->old = (GdkPixbufDrawOpts){0, {0, 0, 0, 0}, 0, 0, GDK_INTERP_NEAREST, cache->last_pixbuf, 0, 0}; return cache; }
static GdkPixbuf* gwy_app_recent_file_list_get_failed_pixbuf(void) { static GdkPixbuf *failed_pixbuf = NULL; if (!failed_pixbuf) { failed_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, THUMB_SIZE, THUMB_SIZE); gwy_debug_objects_creation(G_OBJECT(failed_pixbuf)); gdk_pixbuf_fill(failed_pixbuf, 0); } return failed_pixbuf; }
int main (int argc, char **argv) { GTimer *timer; int i,j; gtk_init (&argc, &argv); GdkPixbuf *pixbuf[4], *ret; pixbuf[0] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 400, 600); pixbuf[1] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 40, 60); pixbuf[2] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 400, 600); pixbuf[3] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 40, 60); for (j=0; j<4; j++) fill_pixbuf (pixbuf[j]); timer = g_timer_new (); g_timer_start (timer); for (i = 0; i < 10 ; i++) { for (j=0; j<4; j++) { ret = gdk_pixbuf_scale_simple (pixbuf[j], 700, 900, GDK_INTERP_BILINEAR); gdk_pixbuf_unref (ret); ret = gdk_pixbuf_scale_simple (pixbuf[j], 20, 50, GDK_INTERP_BILINEAR); gdk_pixbuf_unref (ret); } } g_timer_stop (timer); total_seconds += g_timer_elapsed (timer, NULL); g_print ("time spent scaling (in seconds): %lf\n", total_seconds ); return 0; }
static void overlay_draw(struct graphics_priv *parent, struct graphics_priv *overlay, int window) { #if 0 GdkPixbuf *pixbuf,*pixbuf2; GtkWidget *widget=parent->widget; guchar *pixels1, *pixels2, *p1, *p2; int x,y; int rowstride1,rowstride2; int n_channels1,n_channels2; if (! parent->drawable) return; pixbuf=gdk_pixbuf_get_from_drawable(NULL, overlay->drawable, NULL, 0, 0, 0, 0, overlay->width, overlay->height); pixbuf2=gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf), TRUE, gdk_pixbuf_get_bits_per_sample(pixbuf), gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); rowstride1 = gdk_pixbuf_get_rowstride (pixbuf); rowstride2 = gdk_pixbuf_get_rowstride (pixbuf2); pixels1=gdk_pixbuf_get_pixels (pixbuf); pixels2=gdk_pixbuf_get_pixels (pixbuf2); n_channels1 = gdk_pixbuf_get_n_channels (pixbuf); n_channels2 = gdk_pixbuf_get_n_channels (pixbuf2); for (y = 0 ; y < overlay->height ; y++) { for (x = 0 ; x < overlay->width ; x++) { p1 = pixels1 + y * rowstride1 + x * n_channels1; p2 = pixels2 + y * rowstride2 + x * n_channels2; p2[0]=p1[0]; p2[1]=p1[1]; p2[2]=p1[2]; p2[3]=127; } } if (window) gdk_draw_pixmap(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], overlay->background, 0, 0, overlay->p.x, overlay->p.y, overlay->width, overlay->height); else gdk_draw_pixmap(overlay->background, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, overlay->p.x, overlay->p.y, 0, 0, overlay->width, overlay->height); gdk_draw_pixbuf(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], pixbuf2, 0, 0, overlay->p.x, overlay->p.y, overlay->width, overlay->height, GDK_RGB_DITHER_NONE, 0, 0); if (window) gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, overlay->p.x, overlay->p.y, overlay->p.x, overlay->p.y, overlay->width, overlay->height); #if 0 gdk_draw_pixmap(gr->gra->drawable, gr->gra->widget->style->fg_gc[GTK_WIDGET_STATE(gr->gra->widget)], img->gra->drawable, 0, 0, p->x, p->y, img->gra->width, img->gra->height); #endif #endif }
/*LGPL'd*/ GdkPixbuf * eel_create_colorized_pixbuf (GdkPixbuf *src, int red_value, int green_value, int blue_value) { int i, j; int width, height, has_alpha, src_row_stride, dst_row_stride; guchar *target_pixels; guchar *original_pixels; guchar *pixsrc; guchar *pixdest; GdkPixbuf *dest; g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) && gdk_pixbuf_get_n_channels (src) == 3) || (gdk_pixbuf_get_has_alpha (src) && gdk_pixbuf_get_n_channels (src) == 4), NULL); g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL); dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), gdk_pixbuf_get_has_alpha (src), gdk_pixbuf_get_bits_per_sample (src), gdk_pixbuf_get_width (src), gdk_pixbuf_get_height (src)); has_alpha = gdk_pixbuf_get_has_alpha (src); width = gdk_pixbuf_get_width (src); height = gdk_pixbuf_get_height (src); src_row_stride = gdk_pixbuf_get_rowstride (src); dst_row_stride = gdk_pixbuf_get_rowstride (dest); target_pixels = gdk_pixbuf_get_pixels (dest); original_pixels = gdk_pixbuf_get_pixels (src); for (i = 0; i < height; i++) { pixdest = target_pixels + i*dst_row_stride; pixsrc = original_pixels + i*src_row_stride; for (j = 0; j < width; j++) { *pixdest++ = (*pixsrc++ * red_value) >> 8; *pixdest++ = (*pixsrc++ * green_value) >> 8; *pixdest++ = (*pixsrc++ * blue_value) >> 8; if (has_alpha) { *pixdest++ = *pixsrc++; } } } return dest; }
static void gwy_color_axis_adjust(GwyColorAxis *axis, gint width, gint height) { gint i, j, rowstride, palsize, dval; guchar *pixels, *line; const guchar *samples, *s; gdouble cor; gwy_debug(""); gwy_object_unref(axis->pixbuf); axis->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height); gwy_debug_objects_creation(G_OBJECT(axis->pixbuf)); /*render pixbuf according to orientation*/ pixels = gdk_pixbuf_get_pixels(axis->pixbuf); rowstride = gdk_pixbuf_get_rowstride(axis->pixbuf); samples = gwy_gradient_get_samples(axis->gradient, &palsize); if (axis->orientation == GTK_ORIENTATION_VERTICAL) { cor = (palsize-1.0)/height; for (i = 0; i < height; i++) { line = pixels + i*rowstride; dval = (gint)((height-i-1)*cor + 0.5); for (j = 0; j < width*height; j += height) { s = samples + 4*dval; *(line++) = *(s++); *(line++) = *(s++); *(line++) = *s; } } } if (axis->orientation == GTK_ORIENTATION_HORIZONTAL) { cor = (palsize-1.0)/width; for (i = 0; i < height; i++) { line = pixels + i*rowstride; for (j = 0; j < width*height; j += height) { dval = (gint)((j/height)*cor + 0.5); s = samples + 4*dval; *(line++) = *(s++); *(line++) = *(s++); *(line++) = *s; } } } }
void wxAnimationCtrl::ClearToBackgroundColour() { wxSize sz = GetClientSize(); GdkPixbuf *newpix = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, sz.GetWidth(), sz.GetHeight()); if (!newpix) return; wxColour clr = GetBackgroundColour(); guint32 col = (clr.Red() << 24) | (clr.Green() << 16) | (clr.Blue() << 8); gdk_pixbuf_fill(newpix, col); gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), newpix); g_object_unref(newpix); }
static GdkPixbuf * create_new_pixbuf (GdkPixbuf *src) { g_assert (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB); g_assert ((!gdk_pixbuf_get_has_alpha (src) && gdk_pixbuf_get_n_channels (src) == 3) || (gdk_pixbuf_get_has_alpha (src) && gdk_pixbuf_get_n_channels (src) == 4)); return gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), gdk_pixbuf_get_has_alpha (src), gdk_pixbuf_get_bits_per_sample (src), gdk_pixbuf_get_width (src), gdk_pixbuf_get_height (src)); }
GdkPixbuf* create_void_pixbuf (int width, int height) { GdkPixbuf *p; p = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height); gdk_pixbuf_fill (p, 0xFFFFFF00); return p; }
/** * test_get_set_selection: * * Ensure that getting and setting the selection rectangle works when * the view shows a pixbuf. **/ static void test_get_set_selection () { printf ("test_get_set_selection\n"); setup (); GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 50, 50); gtk_image_view_set_pixbuf (view, pixbuf, FALSE); GdkRectangle sel = {10, 11, 12, 13}; gtk_image_tool_selector_set_selection (selector, &sel); GdkRectangle ret; gtk_image_tool_selector_get_selection (selector, &ret); assert (gdk_rectangle_eq (ret, (GdkRectangle){10, 11, 12, 13})); g_object_unref (pixbuf); teardown(); }
/** * test_cache_is_used_on_equal_opts: * * The objective of this test is to verify that the cache is used when * the new draw options are identical to the old ones if the area is * smaller than the cached pixbuf. If so, the #GdkPixbufDrawMethod * should be %GDK_PIXBUF_DRAW_METHOD_CONTAINS. **/ static void test_cache_is_used_on_equal_opts () { printf ("test_cache_is_used_on_equal_opts\n"); int interp = GDK_INTERP_BILINEAR; GdkRectangle area = {0, 0, 10, 10}; GdkPixbuf *pb = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 30, 30); GdkPixbufDrawOpts o1 = {1, area, 0, 0, interp, pb, 0, 0}; GdkPixbufDrawOpts o2 = {1, area, 0, 0, interp, pb, 0, 0}; GdkPixbufDrawMethod meth = gdk_pixbuf_draw_cache_get_method (&o1, &o2); assert (meth == GDK_PIXBUF_DRAW_METHOD_CONTAINS); g_object_unref (pb); }
GdkPixbuf * go_image_get_pixbuf (GOImage *image) { g_return_val_if_fail (image != NULL, NULL); if (!image->pixbuf) { if (image->width == 0 || image->height == 0 || image->data == NULL) return NULL; image->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, image->width, image->height); } if (image->target_cairo) { cairo_to_pixbuf (image); image->target_cairo = FALSE; } return image->pixbuf; }
GpImage * gp_image_new ( gint width, gint height, gboolean has_alpha ) { GpImage *image; g_return_val_if_fail (width > 0, NULL); g_return_val_if_fail (height > 0, NULL); image = g_object_new (GP_TYPE_IMAGE, NULL); image->priv->pixbuf = gdk_pixbuf_new ( GDK_COLORSPACE_RGB, has_alpha, BITS_PER_SAMPLE, width, height); g_assert(image->priv->pixbuf); g_object_set_data ( G_OBJECT(image), "pixbuf", image->priv->pixbuf); return image; }
/** * test_scroll_needed_if_rect_size_not_equal: * * The objective of this test is to verify that a scroll operation is * needed if the size of the rectangle changes. **/ static void test_scroll_needed_if_rect_size_not_equal () { printf ("test_scroll_needed_if_rect_size_not_equal\n"); int interp = GDK_INTERP_BILINEAR; GdkPixbuf *pb = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 9, 9); GdkPixbufDrawOpts o1 = {1, (GdkRectangle){0, 0, 20, 20}, 0, 0, interp, pb, 0, 0}; GdkPixbufDrawOpts o2 = {1, (GdkRectangle){20, 0, 10, 10}, 0, 0, interp, pb, 0, 0}; GdkPixbufDrawMethod meth = gdk_pixbuf_draw_cache_get_method (&o1, &o2); assert (meth == GDK_PIXBUF_DRAW_METHOD_SCROLL); g_object_unref (pb); }
/** * test_contains_even_if_cache_to_small: * * The objective of this test is to verfy that the method is * %GDK_PIXBUF_DRAW_METHOD_CONTAINS even if the cache is smaller than the * requsted draw area. **/ static void test_contains_even_if_cache_to_small () { printf ("test_contains_even_if_cache_to_small\n"); int interp = GDK_INTERP_BILINEAR; GdkRectangle area = {0, 0, 20, 20}; GdkPixbuf *draw_pb = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 30, 30); GdkPixbufDrawOpts o1 = {1, area, 0, 0, interp, draw_pb, 0, 0}; GdkPixbufDrawOpts o2 = {1, area, 0, 0, interp, draw_pb, 0, 0}; GdkPixbufDrawMethod meth = gdk_pixbuf_draw_cache_get_method (&o1, &o2); assert (meth == GDK_PIXBUF_DRAW_METHOD_CONTAINS); g_object_unref (draw_pb); }
/** * test_default_draw_options: * * The objective of this test is to verify that the default draw * options in the pixbuf draw cache results in the correct draw * method. **/ static void test_default_draw_options () { printf ("test_default_draw_options\n"); GdkPixbufDrawCache *cache = gdk_pixbuf_draw_cache_new (); int interp = GDK_INTERP_BILINEAR; GdkPixbuf *pb = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 9, 9); GdkPixbufDrawOpts o = {1, (GdkRectangle){0, 0, 20, 20}, 0, 0, interp, pb, 0, 0}; GdkPixbufDrawMethod meth = gdk_pixbuf_draw_cache_get_method (&cache->old, &o); assert (meth == GDK_PIXBUF_DRAW_METHOD_SCALE); gdk_pixbuf_draw_cache_free (cache); g_object_unref (pb); }
static void set_color_icon (GdkDragContext * context, GdkColor * color) { GdkPixbuf *pixbuf; guint32 pixel; pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32); pixel = ((color->red & 0xff00) << 16) | ((color->green & 0xff00) << 8) | (color->blue & 0xff00); gdk_pixbuf_fill (pixbuf, pixel); gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2); g_object_unref (pixbuf); }