Exemplo n.º 1
0
void
fb_bg_composite(GdkDrawable *base, GdkGC *gc, guint32 tintcolor, gint alpha)
{
    GdkPixbuf *ret, *ret2;
    int w, h;
    static GdkColormap *cmap = NULL;
    
    ENTER;
    gdk_drawable_get_size (base, &w, &h);
    if (!cmap) {
        cmap = gdk_colormap_get_system ();
    }
    DBG("here\n");
    ret = gdk_pixbuf_get_from_drawable (NULL, base, cmap, 0, 0, 0, 0, w, h);
    if (!ret)
        RET();
    DBG("here w=%d h=%d\n", w, h);
    ret2 = gdk_pixbuf_composite_color_simple(ret, w, h, 
          GDK_INTERP_HYPER, 255-alpha, MIN(w, h), tintcolor, tintcolor);
    DBG("here\n");
    if (!ret2) {
        g_object_unref(ret);
        RET();
    }
    //gdk_pixbuf_render_to_drawable (ret2, base, gc, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0);
    gdk_draw_pixbuf (base, gc, ret2, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0);
    g_object_unref(ret);
    g_object_unref(ret2);
    RET();
}
Exemplo n.º 2
0
/* ------------------------------
 * gap_pview_render_f_from_pixbuf (slow)
 * ------------------------------
 * render drawing_area widget from src_pixbuf buffer
 * scaling and flattening against checkerboard background
 * is done implicite using GDK-pixbuf procedures
 *            
 * Thumbnails at size 128 rendered to Widget Size 256x256 pixels
 * at my Pentium IV 2600 MHZ
 * can be Played at Speed of  98 Frames/sec without dropping frames.
 *
 * The other Implementation without GDK-pixbuf procedures
 * is faster (at least on my machine), therefore GAP_PVIEW_USE_GDK_PIXBUF_RENDERING
 * is NOT defined per default.
 */
void
gap_pview_render_f_from_pixbuf (GapPView *pv_ptr
  , GdkPixbuf *src_pixbuf
  , gint32 flip_request
  , gint32 flip_status
  )
{
  static int l_checksize_tab[17] = { 2, 4, 8, 8, 16, 16, 16, 32, 32, 32, 32, 32, 32, 64, 64, 64, 64 };
  int l_check_size;

  /* printf("gap_pview_render_f_from_pixbuf --- USE GDK-PIXBUF procedures\n"); */
  
  if(pv_ptr == NULL) { return; }
  if(pv_ptr->da_widget == NULL) { return; }
  if(pv_ptr->da_widget->window == NULL)
  { 
    if(gap_debug)
    {
      printf("gap_pview_render_f_from_pixbuf: drawing_area window pointer is NULL, cant render\n");
    }
    return ;
  }

  if(src_pixbuf == NULL)
  {
    if(gap_debug)
    {
      printf("gap_pview_render_f_from_pixbuf: src_pixbuf is NULL, cant render\n");
    }
    return ;
  }

  /* clear flag to let gap_pview_repaint procedure know
   * to use the pixbuf rather than pv_area_data or pixmap for refresh
   */
  pv_ptr->use_pixmap_repaint = FALSE;
  pv_ptr->use_pixbuf_repaint = TRUE;
  p_free_desaturated_area_data(pv_ptr);

  /* l_check_size must be a power of 2 (using fixed size for 1.st test) */
  l_check_size = l_checksize_tab[MIN((pv_ptr->pv_check_size >> 2), 8)];
  if(pv_ptr->pixbuf)
  {
    /* free old (refresh) pixbuf if there is one */
    g_object_unref(pv_ptr->pixbuf);
  }
  
  /* scale and flatten the pixbuf */
  pv_ptr->pixbuf = gdk_pixbuf_composite_color_simple(
                         src_pixbuf
                      , (int) pv_ptr->pv_width
                      , (int) pv_ptr->pv_height
                      , GDK_INTERP_NEAREST
                      , 255                          /* overall_alpha */
                      , (int)l_check_size            /* power of 2 required */
                      , PREVIEW_BG_GRAY1_GDK
                      , PREVIEW_BG_GRAY2_GDK
                      );
  if(gap_debug)
  {
    int nchannels;
    int rowstride;
    int width;
    int height;
    guchar *pix_data;
    gboolean has_alpha;

    width = gdk_pixbuf_get_width(pv_ptr->pixbuf);
    height = gdk_pixbuf_get_height(pv_ptr->pixbuf);
    nchannels = gdk_pixbuf_get_n_channels(pv_ptr->pixbuf);
    pix_data = gdk_pixbuf_get_pixels(pv_ptr->pixbuf);
    has_alpha = gdk_pixbuf_get_has_alpha(pv_ptr->pixbuf);
    rowstride = gdk_pixbuf_get_rowstride(pv_ptr->pixbuf);

    printf("gap_pview_render_f_from_pixbuf (AFTER SCALE/FLATTEN):\n");
    printf(" l_check_size: %d (%d)\n", (int)l_check_size, pv_ptr->pv_check_size);
    printf(" width: %d\n", (int)width );
    printf(" height: %d\n", (int)height );
    printf(" nchannels: %d\n", (int)nchannels );
    printf(" pix_data: %d\n", (int)pix_data );
    printf(" has_alpha: %d\n", (int)has_alpha );
    printf(" rowstride: %d\n", (int)rowstride );
  }

  {
    gint32 l_flip_to_perform;
  
    l_flip_to_perform = p_calculate_flip_request(pv_ptr, flip_request, flip_status);
    if(l_flip_to_perform != GAP_STB_FLIP_NONE)
    {
      p_replace_pixbuf_by_flipped_pixbuf(pv_ptr, l_flip_to_perform);
    }
  }

  gap_pview_repaint(pv_ptr);

}       /* end gap_pview_render_f_from_pixbuf */
Exemplo n.º 3
0
//__________________________________________________________________
void        _HYPlatformButtonBar::_Paint (Ptr p)
{
    _HYButtonBar * theParent = (_HYButtonBar*)this;

    if (theParent->parentWindow->window) {
        GdkRectangle    cRect    = HYRect2GDKRect(*(_HYRect*)p),
                        iRect;

        if (!bbGC) {
            bbGC                 = gdk_gc_new (theParent->parentWindow->window);
            gdk_gc_set_line_attributes (bbGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
        }

        cRect.x += theParent->parentWindow->allocation.x;
        cRect.y += theParent->parentWindow->allocation.y;

        if (!(theParent->settings.width&HY_COMPONENT_TRANSP_BG)) {
            gdk_gc_set_foreground(bbGC,&backFill);
            gdk_draw_rectangle(theParent->parentWindow->window,bbGC,true,cRect.x, cRect.y, cRect.width, cRect.height);
        }


        gdk_gc_set_clip_rectangle(bbGC,&cRect);

        cRect.x  = buttonRect.x;
        cRect.y  = buttonRect.y;

        int   step   = theParent->GetButtonDim()+2*HY_BUTTONBAR_BORDER;

        cRect.width  = cRect.height = step;

        gdk_gc_set_foreground(bbGC,&buttonBorder1);
        for (long i=0; i<theParent->ButtonCount(); i++) {
            if (i&& i%theParent->BarWidth()==0) {
                cRect.x  =  buttonRect.x;
                cRect.y  += step;
            }

            iRect    = cRect;
            iRect.x += theParent->parentWindow->allocation.x + HY_BUTTONBAR_BORDER;
            iRect.y += theParent->parentWindow->allocation.y + HY_BUTTONBAR_BORDER;

            iRect.width  -= 2*HY_BUTTONBAR_BORDER;
            iRect.height -= 2*HY_BUTTONBAR_BORDER;

            GdkPixbuf * buttonToPlot = nil;

            if (theParent->activationFlag) {
                if (i==pushed) {
                    buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1024,0x00000000,0x00000000);
                } else {
                    if (theParent->enabledButtons.Find(i)>=0) {
                        buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,255,1024,0,0);
                    } else {
                        buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1,0x00ffffff,0x00888888);
                    }
                }
            } else {
                buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1,0x00ffffff,0x00888888);
            }
            gdk_draw_pixbuf (theParent->parentWindow->window,bbGC, buttonToPlot, 0,0, iRect.x, iRect.y, iRect.width, iRect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
            g_object_unref (buttonToPlot);
            iRect.x --;
            iRect.y --;
            iRect.width += 2;
            iRect.height += 2;

            gdk_draw_rectangle(theParent->parentWindow->window,bbGC,false,iRect.x, iRect.y, iRect.width, iRect.height);
            cRect.x +=step;
        }
        gdk_gc_set_clip_rectangle(bbGC,nil);

    }

    (*theParent)._HYPlatformComponent::_Paint(p);
}