BitmapTools.h

Go to the documentation of this file.
00001 #ifndef _BITMAP_TOOLS_H
00002 #define _BITMAP_TOOLS_H
00003 
00004 #include <GraphicsDefs.h>
00005 #include <InterfaceDefs.h>
00006 #include <Rect.h>
00007 #include <Point.h>
00008 
00009 class BBitmap;
00010 class BRect;
00011 class BPoint;
00012 
00013 namespace BExperimental {
00014 
00015 typedef rgb_color (*pixel_reader)(const uint8* pixel, const color_map* cmap);
00016 typedef void (*pixel_writer)(uint8* pixel, const rgb_color color, const color_map* cmap);
00017 
00018 class pixel_access
00019 {
00020 public:
00021     pixel_access();
00022     pixel_access(color_space space);
00023     ~pixel_access();
00024     
00025     status_t set_to(color_space space);
00026     
00027     bool valid() const;
00028     
00029     inline size_t bpp() const
00030     {
00031         return fBPP;
00032     }
00033     
00034     inline rgb_color read(const uint8* const pixel) const
00035     {
00036         return (*fReader)(pixel, fColorMap);
00037     }
00038     
00039     inline void write(uint8* const pixel, const rgb_color color)
00040     {
00041         (*fWriter)(pixel, color, fColorMap);
00042     }
00043     
00044 
00045 private:
00046     // actually public variables due to inlines.
00047     const color_map *fColorMap;
00048     size_t fBPP;
00049     pixel_reader fReader;
00050     pixel_writer fWriter;
00051 };
00052     
00053 status_t mix_bitmaps(BBitmap* dest,
00054                      const BBitmap* src1, const BBitmap* src2, uint8 amount);
00055 
00056 status_t scale_bitmap(BBitmap* dest, const BBitmap* src);
00057 
00058 status_t blend_bitmap_color(BBitmap* dest, rgb_color color, uint8 amount=0);
00059 
00060 // Deallocate returned array with free().
00061 uint8* make_stencil(const BBitmap* src, rgb_color background, uint8 slop=0);
00062 
00063 status_t copy_bitmap(BBitmap* dest,
00064                      const BBitmap* src, BRect srcRect, BPoint destPnt,
00065                      drawing_mode mode=B_OP_COPY, uint8* stencil=NULL);
00066 
00067 status_t set_bitmap(BBitmap* dest, const BBitmap* src, bool dither=true);
00068 
00069 }   // namespace BExperimental
00070 
00071 using namespace BExperimental;
00072 
00073 #endif

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.