Logo Search packages:      
Sourcecode: wallpaper-tray version File versions  Download package

void Applet::RenderThumbnail ( Glib::ustring  _szFile  ) 

Renders a thumbnail of the given wallpaper to the m_pThumbnail member.

<Applet::RenderThumbnail>

Parameters:
_szFile The file to thumbnail.
Date:
12-11-2006 GAF Written

Definition at line 332 of file Applet.cc.

References GetSize(), and Horizontal().

Referenced by Applet(), and RenderAndSetThumbnail().

{
      Glib::RefPtr<Gdk::Pixbuf> p_GdkPixbuf = Glib::RefPtr<Gdk::Pixbuf>();

      int n_TargetW, n_TargetH;

      // get thumbnail size
      if(Applet::Horizontal() == true)
      {
          n_TargetW = static_cast<int>(Applet::GetSize() * 1.3f);
          n_TargetH = Applet::GetSize();
      }// end if
      else
      {
          n_TargetW = Applet::GetSize();
          n_TargetH = static_cast<int>(Applet::GetSize() * 0.77f);
      }

      // attempt to create a thumbnail
      try
      {
            p_GdkPixbuf = Gdk::Pixbuf::create_from_file(_szFile);
      }// end try
      catch(...)
      {
            // bugger, slap a black square in there for now
          p_GdkPixbuf = Gdk::Pixbuf::create     (
                        Gdk::COLORSPACE_RGB, 0, 8,
                        n_TargetW, n_TargetH
                  );

            p_GdkPixbuf->fill(0x000000ff);

            m_GtkImage.set(p_GdkPixbuf);

            return;
      }// end catch

      // only scale down if we're sure the starting image is completely larger than the destination size
      if(p_GdkPixbuf->get_width() < n_TargetW || p_GdkPixbuf->get_height() < n_TargetH)
      {
            m_pThumbnail = p_GdkPixbuf;
      }// end if
      else
      {
          m_pThumbnail = Gnome::UI::thumbnail_scale_down_pixbuf   (
                        p_GdkPixbuf,
                        n_TargetW,
                        n_TargetH
                  );
      }// end else
}// end Applet::RenderThumbnail


Generated by  Doxygen 1.6.0   Back to index