Wt::Pixmap Class Reference

#include <pixmap.h>

Inheritance diagram for Wt::Pixmap:

Inheritance graph
[legend]
Collaboration diagram for Wt::Pixmap:

Collaboration graph
[legend]
List of all members.

Public Types

 NoOptim
 BestOptim
 DefaultOptim = BestOptim
enum  Optimization { NoOptim, BestOptim, DefaultOptim = BestOptim }

Public Member Functions

 Pixmap ()
 constructor for NULL pixmap or default display
 Pixmap (int w, int h, int depth=-1, int flags=0, Optimization optimization=DefaultOptim)
 constructor for a sized, non display, pixmap
 Pixmap (const Size &size, int depth=-1, int flags=0, Optimization optimization=DefaultOptim)
 constructor for a sized, non display, pixmap
 Pixmap (const PixmapBase &pixmap)
 copy shares the pixmap
 Pixmap (const SDLSurface &sdlsurface)
 constructor from SDLSurface (for scale to work implicitely)
 Pixmap (const std::string &filename)
 constructor from file
void fill (const Color &color=Color("white"))
void fill (const Rect &dst, const Color &color=Color("white"))
void fill (const Region &dst, const Color &color=Color("white"))
void blend (const Color &color=Color("white"), int alpha_blend_factor=Color::Transparent)
void blend (const Rect &dst, const Color &color=Color("white"), int alpha_blend_factor=Color::Transparent)
void blend (const Region &dst, const Color &color=Color("white"), int alpha_blend_factor=Color::Transparent)
int blit (const Point &p, const PixmapBase &src)
int blit (const Point &p, const PixmapBase &src, const Rect &src_rect)
int blitAlphaCopy (const Point &p, const PixmapBase &src)
int blitAlphaCopy (const Point &p, const PixmapBase &src, const Rect &src_rect)
int blitAlphaBlend (int x, int y, const PixmapBase &src, const Rect &src_rect, int alpha_blend_factor=Color::Transparent)
 copy to from src rect with alpha blending
int blitAlphaBlend (const PixmapBase &src, int alpha_blend_factor=Color::Transparent)
 copy to from src with alpha blending
int blitAlphaBlend (int x, int y, const PixmapBase &src, int alpha_blend_factor=Color::Transparent)
 copy to from src with alpha blending
int blitAlphaBlend (const Point &p, const PixmapBase &src, int alpha_blend_factor=Color::Transparent)
int blitAlphaBlend (const Point &p, const PixmapBase &src, const Rect &src_rect, int alpha_blend_factor=Color::Transparent)
void resize (const Size &size)
PixmapBase scale (const Size &size, SDLSurface::ScaleMode mode=SDLSurface::ScaleFree) const
PixmapBase smoothScale (const Size &size, SDLSurface::ScaleMode mode=SDLSurface::ScaleFree) const
int pixel (const Point &p) const
Color pixelColor (const Point &p) const
void setPixel (const Point &p, int pixel_value)
void setPixelColor (const Point &p, const SDLColor &color)
PixmapBase copy () const
PixmapBase copy (int x, int y, int w, int h) const
PixmapBase copy (const Rect &r) const
Informative methods
bool isNull () const
Size size () const
Rect rect () const

Protected Types

typedef PixmapOf< SDLSurfacePixmapBase

Detailed Description

Definition at line 288 of file pixmap.h.


Member Typedef Documentation

template<typename SDLPixmap>
typedef PixmapOf<SDLSurface> Wt::PixmapOf< SDLPixmap >::PixmapBase [protected, inherited]

Definition at line 36 of file pixmap.h.


Member Enumeration Documentation

enum Wt::Pixmap::Optimization

Enumerator:
NoOptim 
BestOptim 
DefaultOptim 

Definition at line 290 of file pixmap.h.

00290                  {
00291         NoOptim,
00292         BestOptim,
00293         DefaultOptim = BestOptim
00294     } Optimization;


Constructor & Destructor Documentation

Wt::Pixmap::Pixmap (  )  [inline]

constructor for NULL pixmap or default display

Definition at line 297 of file pixmap.h.

Referenced by Wt::Label::setText(), and Wt::Widget::updateBackground().

00298             : PixmapBase() {}

Wt::Pixmap::Pixmap ( int  w,
int  h,
int  depth = -1,
int  flags = 0,
Optimization  optimization = DefaultOptim 
) [inline]

constructor for a sized, non display, pixmap

Definition at line 301 of file pixmap.h.

References BestOptim.

00302             :  PixmapOf<SDLSurface>(w, h, depth, flags) {
00303         if (optimization == BestOptim)
00304             convertToDisplay();
00305     }

Wt::Pixmap::Pixmap ( const Size size,
int  depth = -1,
int  flags = 0,
Optimization  optimization = DefaultOptim 
) [inline]

constructor for a sized, non display, pixmap

Definition at line 307 of file pixmap.h.

References BestOptim.

00308             :  PixmapOf<SDLSurface>(size.width(), size.height(), depth, flags) {
00309         if (optimization == BestOptim)
00310             convertToDisplay();
00311     }

Wt::Pixmap::Pixmap ( const PixmapBase pixmap  )  [inline]

copy shares the pixmap

Definition at line 314 of file pixmap.h.

00315         : PixmapBase(pixmap) {}

Wt::Pixmap::Pixmap ( const SDLSurface sdlsurface  )  [inline]

constructor from SDLSurface (for scale to work implicitely)

Definition at line 317 of file pixmap.h.

00318             : PixmapBase(sdlsurface) {}

Wt::Pixmap::Pixmap ( const std::string &  filename  )  [inline]

constructor from file

Definition at line 320 of file pixmap.h.

00321             : PixmapBase(filename) {}


Member Function Documentation

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::blend ( const Region dst,
const Color color = Color("white"),
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

Definition at line 138 of file pixmap.h.

00139                                                           {
00140         const RectArray& ra = dst.rects();
00141         const int n = ra.size();
00142 
00143         for (int i = 0; i < n; i++) {
00144             blend(ra[i], color, alpha_blend_factor);
00145         }
00146     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::blend ( const Rect dst,
const Color color = Color("white"),
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

Definition at line 96 of file pixmap.h.

00097                                                           {
00098 
00099         switch(color.alpha()) {
00100         case Color::Transparent:
00101             return;
00102         case Color::Opaque:
00103             fill(dst, color);
00104             return;
00105         default:
00106             break;
00107         }
00108 
00109         const Rect overlap = dst.intersect(SDLPixmap::clipRect());
00110         if(overlap.isEmpty())
00111             return;
00112 
00113         int new_part, old_part;
00114         Color::calcBlendFactors(color.alpha(), new_part, old_part);
00115         int alpha_new_part, alpha_old_part;
00116         Color::calcBlendFactors(alpha_blend_factor, alpha_new_part, alpha_old_part);
00117 
00118         SDLPixmap::lock()
00119             ;
00120         const int bpp = SDLPixmap::pixelFormat().bytesPerPixel();
00121         for(int y = overlap.y(); y < overlap.y() + overlap.height(); y++) {
00122             int offset = SDLPixmap::pixelOffset(overlap.x(), y);
00123             for(int x = overlap.x(); x < overlap.x() + overlap.width(); x++) {
00124 
00125                 Color c = SDLPixmap::pixelColor(offset);
00126                 c = Color::blend(c, old_part, color, new_part,
00127                                  alpha_new_part, alpha_old_part);
00128 
00129                 SDLPixmap::setPixelColor(offset, c);
00130                 offset += bpp;
00131             }
00132         }
00133         SDLPixmap::unlock();
00134 
00135         return;
00136     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::blend ( const Color color = Color("white"),
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

Definition at line 91 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::Painter::blendRect(), and Wt::Painter::blendRegion().

00092                                                           {
00093         blend(rect(), SDLPixmap::pixelFormat().mapToPixelValue(color), alpha_blend_factor);
00094     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blit ( const Point p,
const PixmapBase src,
const Rect src_rect 
) [inline, inherited]

Definition at line 152 of file pixmap.h.

00152                                                                           {
00153         return blit(p.x(), p.y(), src, src_rect);
00154     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blit ( const Point p,
const PixmapBase src 
) [inline, inherited]

Definition at line 149 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blit(), Wt::RootWindow::blit_region(), Wt::PixmapOf< Wt::SDLSurface >::copy(), Wt::Painter::drawPixmap(), Wt::Painter::drawText(), and Wt::Painter::drawTiledPixmap().

00149                                                     {
00150         return blit(p.x(), p.y(), src);
00151     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blitAlphaBlend ( const Point p,
const PixmapBase src,
const Rect src_rect,
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

Definition at line 230 of file pixmap.h.

00231                                                                   {
00232         return blitAlphaBlend(p.x(), p.y(), src, src_rect, alpha_blend_factor);
00233     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blitAlphaBlend ( const Point p,
const PixmapBase src,
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

Definition at line 226 of file pixmap.h.

00227                                                                   {
00228         return blitAlphaBlend(p.x(), p.y(), src, alpha_blend_factor);
00229     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blitAlphaBlend ( int  x,
int  y,
const PixmapBase src,
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

copy to from src with alpha blending

Definition at line 220 of file pixmap.h.

00221                                                                   {
00222         return blitAlphaBlend(x, y, src,
00223                               Rect(0, 0, src.width(), src.height()),
00224                               alpha_blend_factor);
00225     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blitAlphaBlend ( const PixmapBase src,
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

copy to from src with alpha blending

Definition at line 213 of file pixmap.h.

00214                                                                   {
00215         return blitAlphaBlend(0, 0, src,
00216                               Rect(0, 0, src.width(), src.height()),
00217                               alpha_blend_factor);
00218     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blitAlphaBlend ( int  x,
int  y,
const PixmapBase src,
const Rect src_rect,
int  alpha_blend_factor = Color::Transparent 
) [inline, inherited]

copy to from src rect with alpha blending

if alpha_blend_factor = Color::Transparent (default) we keep the destination alpha (blit semantics). If it is set to Color::Opaque we replace alpha values with the new one (blitAlphaCopy semantics).

The blending of the color happens anyway.

Definition at line 172 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend().

00174                                                                   {
00175         const Rect dst = Rect(x, y, src_rect.width(), src_rect.height());
00176         const Rect overlap = dst.intersect(SDLPixmap::clipRect());
00177 
00178         if(overlap.isEmpty())
00179             return 0;
00180 
00181         assert(SDLPixmap::depth() == src.depth());
00182 
00183         const int bpp = SDLPixmap::pixelFormat().bytesPerPixel();
00184         const int src_bpp = src.pixelFormat().bytesPerPixel();
00185 
00186         int alpha_new_part, alpha_old_part;
00187         Color::calcBlendFactors(alpha_blend_factor, alpha_new_part, alpha_old_part);
00188         SDLPixmap::lock()
00189             ;
00190         for(int y = overlap.y(); y < overlap.y() + overlap.height(); y++) {
00191             int offset = SDLPixmap::pixelOffset(overlap.x(), y);
00192             int src_offset = src.pixelOffset(src_rect.x(), src_rect.y() + y - overlap.y());
00193             for(int x = overlap.x(); x < overlap.x() + overlap.width(); x++) {
00194                 Color c = pixelColor(offset);
00195                 Color src_c = src.pixelColor(src_offset);
00196 
00197                 int new_part, old_part;
00198                 Color::calcBlendFactors(src_c.alpha(), new_part, old_part);
00199                 c = Color::blend(c, old_part, src_c, new_part,
00200                                  alpha_new_part, alpha_old_part);
00201                 SDLPixmap::setPixelColor(offset, c);
00202 
00203                 offset += bpp;
00204                 src_offset += src_bpp;
00205             }
00206         }
00207         SDLPixmap::unlock();
00208 
00209         return 0;
00210     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blitAlphaCopy ( const Point p,
const PixmapBase src,
const Rect src_rect 
) [inline, inherited]

Definition at line 160 of file pixmap.h.

00160                                                                                    {
00161         return blitAlphaCopy(p.x(), p.y(), src, src_rect);
00162     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::blitAlphaCopy ( const Point p,
const PixmapBase src 
) [inline, inherited]

Definition at line 157 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blitAlphaCopy(), and Wt::Painter::drawText().

00157                                                              {
00158         return blitAlphaCopy(p.x(), p.y(), src);
00159     }

template<typename SDLPixmap>
PixmapBase Wt::PixmapOf< SDLPixmap >::copy ( const Rect r  )  const [inline, inherited]

Definition at line 280 of file pixmap.h.

00280                                          {
00281         PixmapBase p(r.width(), r.height());
00282         p.convertTo(*this);
00283         p.blit(0, 0, *this, r);
00284         return p;
00285     }

template<typename SDLPixmap>
PixmapBase Wt::PixmapOf< SDLPixmap >::copy ( int  x,
int  y,
int  w,
int  h 
) const [inline, inherited]

Definition at line 276 of file pixmap.h.

00276                                                       {
00277         return copy(Rect(x, y, w, h));
00278     }

template<typename SDLPixmap>
PixmapBase Wt::PixmapOf< SDLPixmap >::copy (  )  const [inline, inherited]

Definition at line 272 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::copy().

00272                             {
00273         return copy(rect());
00274     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::fill ( const Region dst,
const Color color = Color("white") 
) [inline, inherited]

Definition at line 82 of file pixmap.h.

00082                                                                       {
00083         const RectArray& ra = dst.rects();
00084         const int n = ra.size();
00085 
00086         for (int i = 0; i < n; i++) {
00087             fill(ra[i], color);
00088         }
00089     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::fill ( const Rect dst,
const Color color = Color("white") 
) [inline, inherited]

Definition at line 78 of file pixmap.h.

00078                                                                     {
00079         fill(dst, SDLPixmap::pixelFormat().mapToPixelValue(color));
00080     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::fill ( const Color color = Color("white")  )  [inline, inherited]

Definition at line 75 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::PixmapOf< Wt::SDLSurface >::fill(), Wt::Painter::fillRect(), and Wt::Painter::fillRegion().

00075                                                    {
00076         fill(SDLPixmap::pixelFormat().mapToPixelValue(color));
00077     }

template<typename SDLPixmap>
bool Wt::PixmapOf< SDLPixmap >::isNull (  )  const [inline, inherited]

Definition at line 61 of file pixmap.h.

00061                         {
00062         return (!*this || (SDLPixmap::width() == 0 && SDLPixmap::height() == 0));
00063     }

template<typename SDLPixmap>
int Wt::PixmapOf< SDLPixmap >::pixel ( const Point p  )  const [inline, inherited]

Definition at line 253 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::pixel(), and Wt::Painter::rop().

00253                                     {
00254         return pixel(p.x(), p.y());
00255     }

template<typename SDLPixmap>
Color Wt::PixmapOf< SDLPixmap >::pixelColor ( const Point p  )  const [inline, inherited]

Definition at line 258 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend(), and Wt::PixmapOf< Wt::SDLSurface >::pixelColor().

00258                                            {
00259         return pixelColor(p.x(), p.y());
00260     }

template<typename SDLPixmap>
Rect Wt::PixmapOf< SDLPixmap >::rect (  )  const [inline, inherited]

Reimplemented in Wt::Widget.

Definition at line 69 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::PixmapOf< Wt::SDLSurface >::copy(), Wt::PushButton::drawButton(), Wt::Painter::drawLine(), and Wt::Painter::isClipped().

00069                       {
00070         return Rect(0, 0, SDLPixmap::width(), SDLPixmap::height());
00071     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::resize ( const Size size  )  [inline, inherited]

Reimplemented in Wt::Widget.

Definition at line 236 of file pixmap.h.

Referenced by Wt::Widget::resize(), Wt::RootWindow::resize(), and Wt::PixmapOf< Wt::SDLSurface >::resize().

00236                                   {
00237         resize(size.width(), size.height());
00238     }

template<typename SDLPixmap>
PixmapBase Wt::PixmapOf< SDLPixmap >::scale ( const Size size,
SDLSurface::ScaleMode  mode = SDLSurface::ScaleFree 
) const [inline, inherited]

Definition at line 241 of file pixmap.h.

Referenced by Wt::Painter::drawPixmap(), Wt::PixmapOf< Wt::SDLSurface >::scale(), and Wt::Widget::updateBackground().

00242                                                                            {
00243         return scale(size.width(), size.height(), mode);
00244     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::setPixel ( const Point p,
int  pixel_value 
) [inline, inherited]

Definition at line 263 of file pixmap.h.

Referenced by Wt::Painter::rop(), and Wt::PixmapOf< Wt::SDLSurface >::setPixel().

00263                                                    {
00264         setPixel(p.x(), p.y(), pixel_value);
00265     }

template<typename SDLPixmap>
void Wt::PixmapOf< SDLPixmap >::setPixelColor ( const Point p,
const SDLColor color 
) [inline, inherited]

Definition at line 268 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::setPixelColor().

00268                                                               {
00269         setPixelColor(p.x(), p.y(), color);
00270     }

template<typename SDLPixmap>
Size Wt::PixmapOf< SDLPixmap >::size (  )  const [inline, inherited]

Reimplemented in Wt::Widget.

Definition at line 65 of file pixmap.h.

Referenced by Wt::RootWindow::blit_region(), Wt::Label::drawContents(), Wt::Widget::erase(), Wt::PixmapOf< Wt::SDLSurface >::resize(), Wt::RootWindow::RootWindow(), Wt::PixmapOf< Wt::SDLSurface >::scale(), Wt::PushButton::setButtonSize(), and Wt::PixmapOf< Wt::SDLSurface >::smoothScale().

00065                       {
00066         return Size(SDLPixmap::width(), SDLPixmap::height());
00067     }

template<typename SDLPixmap>
PixmapBase Wt::PixmapOf< SDLPixmap >::smoothScale ( const Size size,
SDLSurface::ScaleMode  mode = SDLSurface::ScaleFree 
) const [inline, inherited]

Definition at line 247 of file pixmap.h.

Referenced by Wt::PixmapOf< Wt::SDLSurface >::smoothScale().

00248                                                                                  {
00249         return smoothScale(size.width(), size.height(), mode);
00250     }


The documentation for this class was generated from the following file:

Generated Fri Jul 28 19:30:55 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.