Compare commits
1 Commits
CPPUNIT_1_
...
before_tem
Author | SHA1 | Date | |
---|---|---|---|
|
ec5ca08106 |
@@ -1,80 +0,0 @@
|
||||
dnl
|
||||
dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_CPPUNIT,
|
||||
[
|
||||
|
||||
AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)],
|
||||
cppunit_config_prefix="$withval", cppunit_config_prefix="")
|
||||
AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)],
|
||||
cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
|
||||
|
||||
if test x$cppunit_config_exec_prefix != x ; then
|
||||
cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
|
||||
if test x${CPPUNIT_CONFIG+set} != xset ; then
|
||||
CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
|
||||
fi
|
||||
fi
|
||||
if test x$cppunit_config_prefix != x ; then
|
||||
cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
|
||||
if test x${CPPUNIT_CONFIG+set} != xset ; then
|
||||
CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
|
||||
cppunit_version_min=$1
|
||||
|
||||
AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
|
||||
no_cppunit=""
|
||||
if test "$CPPUNIT_CONFIG" = "no" ; then
|
||||
no_cppunit=yes
|
||||
else
|
||||
CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
|
||||
CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
|
||||
cppunit_version=`$CPPUNIT_CONFIG --version`
|
||||
|
||||
cppunit_major_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
cppunit_minor_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
cppunit_micro_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
|
||||
cppunit_major_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
cppunit_minor_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
cppunit_micro_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
|
||||
cppunit_version_proper=`expr \
|
||||
$cppunit_major_version \> $cppunit_major_min \| \
|
||||
$cppunit_major_version \= $cppunit_major_min \& \
|
||||
$cppunit_minor_version \> $cppunit_minor_min \| \
|
||||
$cppunit_major_version \= $cppunit_major_min \& \
|
||||
$cppunit_minor_version \= $cppunit_minor_min \& \
|
||||
$cppunit_micro_version \>= $cppunit_micro_min `
|
||||
|
||||
if test "$cppunit_version_proper" = "1" ; then
|
||||
AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
no_cppunit=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$no_cppunit" = x ; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
CPPUNIT_CFLAGS=""
|
||||
CPPUNIT_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
|
||||
AC_SUBST(CPPUNIT_CFLAGS)
|
||||
AC_SUBST(CPPUNIT_LIBS)
|
||||
])
|
||||
|
||||
|
||||
|
300
include/wx/msw/bitmap.h
Normal file
300
include/wx/msw/bitmap.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/bitmap.h
|
||||
// Purpose: wxBitmap class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_BITMAP_H_
|
||||
#define _WX_BITMAP_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "bitmap.h"
|
||||
#endif
|
||||
|
||||
#include "wx/msw/gdiimage.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/palette.h"
|
||||
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
class WXDLLEXPORT wxBitmapHandler;
|
||||
class WXDLLEXPORT wxBitmapRefData;
|
||||
class WXDLLEXPORT wxControl;
|
||||
class WXDLLEXPORT wxCursor;
|
||||
class WXDLLEXPORT wxDC;
|
||||
class WXDLLEXPORT wxDIB;
|
||||
class WXDLLEXPORT wxIcon;
|
||||
class WXDLLEXPORT wxImage;
|
||||
class WXDLLEXPORT wxMask;
|
||||
class WXDLLEXPORT wxPalette;
|
||||
class WXDLLEXPORT wxRawBitmapData;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmap: a mono or colour bitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxBitmap : public wxGDIImage
|
||||
{
|
||||
public:
|
||||
// default ctor creates an invalid bitmap, you must Create() it later
|
||||
wxBitmap() { Init(); }
|
||||
|
||||
// Copy constructors
|
||||
wxBitmap(const wxBitmap& bitmap) { Init(); Ref(bitmap); }
|
||||
|
||||
// Initialize with raw data
|
||||
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
||||
|
||||
// Initialize with XPM data
|
||||
wxBitmap(const char **data) { CreateFromXpm(data); }
|
||||
wxBitmap(char **data) { CreateFromXpm((const char **)data); }
|
||||
|
||||
// Load a file or resource
|
||||
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
|
||||
|
||||
// New constructor for generalised creation from data
|
||||
wxBitmap(void *data, long type, int width, int height, int depth = 1);
|
||||
|
||||
// Create a new, uninitialized bitmap of the given size and depth (if it
|
||||
// is omitted, will create a bitmap compatible with the display)
|
||||
//
|
||||
// NB: this ctor will create a DIB for 24 and 32bpp bitmaps, use ctor
|
||||
// taking a DC argument if you want to force using DDB in this case
|
||||
wxBitmap(int width, int height, int depth = -1);
|
||||
|
||||
// Create a bitmap compatible with the given DC
|
||||
wxBitmap(int width, int height, const wxDC& dc);
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
// Convert from wxImage
|
||||
wxBitmap(const wxImage& image, int depth = -1)
|
||||
{ (void)CreateFromImage(image, depth); }
|
||||
|
||||
// Create a DDB compatible with the given DC from wxImage
|
||||
wxBitmap(const wxImage& image, const wxDC& dc)
|
||||
{ (void)CreateFromImage(image, dc); }
|
||||
#endif // wxUSE_IMAGE
|
||||
|
||||
// we must have this, otherwise icons are silently copied into bitmaps using
|
||||
// the copy ctor but the resulting bitmap is invalid!
|
||||
wxBitmap(const wxIcon& icon) { Init(); CopyFromIcon(icon); }
|
||||
|
||||
wxBitmap& operator=(const wxBitmap& bitmap)
|
||||
{
|
||||
if ( m_refData != bitmap.m_refData )
|
||||
Ref(bitmap);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxBitmap& operator=(const wxIcon& icon)
|
||||
{
|
||||
(void)CopyFromIcon(icon);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxBitmap& operator=(const wxCursor& cursor)
|
||||
{
|
||||
(void)CopyFromCursor(cursor);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~wxBitmap();
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
wxImage ConvertToImage() const;
|
||||
#endif // wxUSE_IMAGE
|
||||
|
||||
// get the given part of bitmap
|
||||
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
||||
|
||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||
bool CopyFromIcon(const wxIcon& icon);
|
||||
|
||||
// copies the contents and mask of the given cursor to the bitmap
|
||||
bool CopyFromCursor(const wxCursor& cursor);
|
||||
|
||||
// copies from a device independent bitmap
|
||||
bool CopyFromDIB(const wxDIB& dib);
|
||||
|
||||
virtual bool Create(int width, int height, int depth = -1);
|
||||
virtual bool Create(int width, int height, const wxDC& dc);
|
||||
virtual bool Create(void *data, long type, int width, int height, int depth = 1);
|
||||
virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE);
|
||||
virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
|
||||
|
||||
wxBitmapRefData *GetBitmapData() const
|
||||
{ return (wxBitmapRefData *)m_refData; }
|
||||
|
||||
// raw bitmap access support functions
|
||||
bool GetRawData(wxRawBitmapData *data);
|
||||
void UngetRawData(wxRawBitmapData *);
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
wxPalette* GetPalette() const;
|
||||
void SetPalette(const wxPalette& palette);
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
wxMask *GetMask() const;
|
||||
void SetMask(wxMask *mask);
|
||||
|
||||
bool operator==(const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
|
||||
bool operator!=(const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
|
||||
|
||||
// these functions are internal and shouldn't be used, they risk to
|
||||
// disappear in the future
|
||||
bool HasAlpha() const;
|
||||
void UseAlpha();
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
// these functions do nothing and are only there for backwards
|
||||
// compatibility
|
||||
wxDEPRECATED( int GetQuality() const );
|
||||
wxDEPRECATED( void SetQuality(int quality) );
|
||||
#endif // WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2
|
||||
void SetOk(bool isOk);
|
||||
#endif // WXWIN_COMPATIBILITY_2
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
#if wxUSE_PALETTE
|
||||
wxPalette *GetColourMap() const { return GetPalette(); }
|
||||
void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
|
||||
#endif // wxUSE_PALETTE
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
public:
|
||||
void SetHBITMAP(WXHBITMAP bmp) { SetHandle((WXHANDLE)bmp); }
|
||||
WXHBITMAP GetHBITMAP() const { return (WXHBITMAP)GetHandle(); }
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
void SetSelectedInto(wxDC *dc);
|
||||
wxDC *GetSelectedInto() const;
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
virtual wxGDIImageRefData *CreateData() const;
|
||||
|
||||
// creates the bitmap from XPM data, supposed to be called from ctor
|
||||
bool CreateFromXpm(const char **bits);
|
||||
|
||||
// creates an uninitialized bitmap, called from Create()s above
|
||||
bool DoCreate(int w, int h, int depth, WXHDC hdc);
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
// creates the bitmap from wxImage, supposed to be called from ctor
|
||||
bool CreateFromImage(const wxImage& image, int depth);
|
||||
|
||||
// creates a DDB from wxImage, supposed to be called from ctor
|
||||
bool CreateFromImage(const wxImage& image, const wxDC& dc);
|
||||
|
||||
// common part of the 2 methods above (hdc may be 0)
|
||||
bool CreateFromImage(const wxImage& image, int depth, WXHDC hdc);
|
||||
#endif // wxUSE_IMAGE
|
||||
|
||||
private:
|
||||
#ifdef __WIN32__
|
||||
// common part of CopyFromIcon/CopyFromCursor for Win32
|
||||
bool CopyFromIconOrCursor(const wxGDIImage& icon);
|
||||
#endif // __WIN32__
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMask: a mono bitmap used for drawing bitmaps transparently.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxMask : public wxObject
|
||||
{
|
||||
public:
|
||||
wxMask();
|
||||
|
||||
// Construct a mask from a bitmap and a colour indicating the transparent
|
||||
// area
|
||||
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
||||
|
||||
// Construct a mask from a bitmap and a palette index indicating the
|
||||
// transparent area
|
||||
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
||||
|
||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
||||
wxMask(const wxBitmap& bitmap);
|
||||
|
||||
// construct a mask from the givne bitmap handle
|
||||
wxMask(WXHBITMAP hbmp) { m_maskBitmap = hbmp; }
|
||||
|
||||
virtual ~wxMask();
|
||||
|
||||
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
||||
bool Create(const wxBitmap& bitmap);
|
||||
|
||||
// Implementation
|
||||
WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
|
||||
void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
|
||||
|
||||
protected:
|
||||
WXHBITMAP m_maskBitmap;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmapHandler is a class which knows how to load/save bitmaps to/from file
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxBitmapHandler : public wxGDIImageHandler
|
||||
{
|
||||
public:
|
||||
wxBitmapHandler() { m_type = wxBITMAP_TYPE_INVALID; }
|
||||
wxBitmapHandler(const wxString& name, const wxString& ext, long type)
|
||||
: wxGDIImageHandler(name, ext, type)
|
||||
{
|
||||
}
|
||||
|
||||
// keep wxBitmapHandler derived from wxGDIImageHandler compatible with the
|
||||
// old class which worked only with bitmaps
|
||||
virtual bool Create(wxBitmap *bitmap,
|
||||
void *data,
|
||||
long flags,
|
||||
int width, int height, int depth = 1);
|
||||
virtual bool LoadFile(wxBitmap *bitmap,
|
||||
const wxString& name,
|
||||
long flags,
|
||||
int desiredWidth, int desiredHeight);
|
||||
virtual bool SaveFile(wxBitmap *bitmap,
|
||||
const wxString& name,
|
||||
int type,
|
||||
const wxPalette *palette = NULL);
|
||||
|
||||
virtual bool Create(wxGDIImage *image,
|
||||
void *data,
|
||||
long flags,
|
||||
int width, int height, int depth = 1);
|
||||
virtual bool Load(wxGDIImage *image,
|
||||
const wxString& name,
|
||||
long flags,
|
||||
int desiredWidth, int desiredHeight);
|
||||
virtual bool Save(wxGDIImage *image,
|
||||
const wxString& name,
|
||||
int type);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_BITMAP_H_
|
262
include/wx/rawbmp.h
Normal file
262
include/wx/rawbmp.h
Normal file
@@ -0,0 +1,262 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/rawbmp.h
|
||||
// Purpose: macros for fast, raw bitmap data access
|
||||
// Author: Eric Kidd, Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 10.03.03
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_RAWBMP_H_BASE_
|
||||
#define _WX_RAWBMP_H_BASE_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Abstract Pixel API
|
||||
//
|
||||
// We need to access our raw bitmap data (1) portably and (2) efficiently.
|
||||
// We do this using a two-dimensional "iteration" interface. Performance
|
||||
// is extremely important here: these functions will be called hundreds
|
||||
// of thousands of times in a row, and even small inefficiencies will
|
||||
// make applications seem slow.
|
||||
//
|
||||
// We can't always rely on inline functions, because not all compilers actually
|
||||
// bother to inline them unless we crank the optimization levels way up.
|
||||
// Therefore, we also provide macros to wring maximum speed out of compiler
|
||||
// unconditionally (e.g. even in debug builds). Of course, if the performance
|
||||
// isn't absolutely crucial for you you shouldn't be using them but the inline
|
||||
// functions instead.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Usage example:
|
||||
|
||||
wxBitmap bmp;
|
||||
wxRawBitmapData data(bitmap);
|
||||
if ( !data )
|
||||
{
|
||||
... raw access to bitmap data unavailable, do something else ...
|
||||
return;
|
||||
}
|
||||
|
||||
if ( data.m_width < 20 || data.m_height < 20 )
|
||||
{
|
||||
... complain: the bitmap it too small ...
|
||||
return;
|
||||
}
|
||||
|
||||
wxRawBitmapIterator p(data);
|
||||
|
||||
// we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
|
||||
p.Offset(10, 10);
|
||||
|
||||
for ( int y = 0; y < 10; ++y )
|
||||
{
|
||||
wxRawBitmapIterator rowStart = p;
|
||||
|
||||
for ( int x = 0; x < 10; ++x, ++p )
|
||||
{
|
||||
p.Red() = r;
|
||||
p.Green() = g;
|
||||
p.Blue() = b;
|
||||
}
|
||||
|
||||
p = rowStart;
|
||||
p.OffsetY(1);
|
||||
}
|
||||
*/
|
||||
|
||||
// this struct represents a pointer to raw bitmap data
|
||||
class wxRawBitmapData
|
||||
{
|
||||
public:
|
||||
// ctor associates this pointer with a bitmap and locks the bitmap for raw
|
||||
// access, it will be unlocked only by our dtor and so these objects should
|
||||
// normally be only created on the stack, i.e. have limited life-time
|
||||
wxRawBitmapData(wxBitmap bmp) : m_bmp(bmp)
|
||||
{
|
||||
if ( !bmp.GetRawData(this) )
|
||||
m_pixels = NULL;
|
||||
}
|
||||
|
||||
// we evaluate to true only if we could get access to bitmap data
|
||||
// successfully
|
||||
operator bool() const { return m_pixels != NULL; }
|
||||
|
||||
// dtor unlocks the bitmap
|
||||
~wxRawBitmapData()
|
||||
{
|
||||
m_bmp.UngetRawData(this);
|
||||
}
|
||||
|
||||
// call this to indicate that we should use the alpha channel
|
||||
void UseAlpha() { m_bmp.UseAlpha(); }
|
||||
|
||||
// accessors
|
||||
unsigned char *GetPixels() const { return m_pixels; }
|
||||
int GetWidth() const { return m_width; }
|
||||
int GetHeight() const { return m_height; }
|
||||
int GetByPP() const { return m_bypp; }
|
||||
int GetBPP() const { return 8*GetByPP(); }
|
||||
int GetRowStride() const { return m_stride; }
|
||||
|
||||
// private: -- public because accessed by the macros below but still mustn't be
|
||||
// used directly
|
||||
|
||||
// the bitmap we're associated with
|
||||
wxBitmap m_bmp;
|
||||
|
||||
// pointer to the start of the data
|
||||
unsigned char *m_pixels;
|
||||
|
||||
// the size of the image we address, in pixels
|
||||
int m_width,
|
||||
m_height;
|
||||
|
||||
// number of bytes (NOT bits) per pixel, including alpha channel if any
|
||||
int m_bypp;
|
||||
|
||||
// this parameter is the offset of the start of the (N+1)st row from the
|
||||
// Nth one and can be different from m_bypp*width in some cases:
|
||||
// a) the most usual one is to force 32/64 bit alignment of rows
|
||||
// b) another one is for bottom-to-top images where it's negative
|
||||
// c) finally, it could conceivably be 0 for the images with all
|
||||
// lines being identical
|
||||
int m_stride;
|
||||
};
|
||||
|
||||
// this is the type for the iterator over raw bitmap data
|
||||
class wxRawBitmapIterator
|
||||
{
|
||||
public:
|
||||
// ctors and such
|
||||
// --------------
|
||||
|
||||
// we must be associated/initialized with some bitmap data object
|
||||
wxRawBitmapIterator(const wxRawBitmapData& data) : m_data(&data)
|
||||
{
|
||||
m_ptr = m_data->GetPixels();
|
||||
}
|
||||
|
||||
// default copy ctor, assignment operator and dtor are ok
|
||||
|
||||
|
||||
// navigation
|
||||
// ----------
|
||||
|
||||
// move x pixels to the right and y down
|
||||
//
|
||||
// note that the rows don't wrap!
|
||||
void Offset(int x, int y)
|
||||
{
|
||||
m_ptr += m_data->GetRowStride()*y + m_data->GetByPP()*x;
|
||||
}
|
||||
|
||||
// move x pixels to the right (again, no row wrapping)
|
||||
void OffsetX(int x)
|
||||
{
|
||||
m_ptr += m_data->GetByPP()*x;
|
||||
}
|
||||
|
||||
// move y rows to the bottom
|
||||
void OffsetY(int y)
|
||||
{
|
||||
m_ptr += m_data->GetRowStride()*y;
|
||||
}
|
||||
|
||||
// go back to (0, 0)
|
||||
void Reset()
|
||||
{
|
||||
m_ptr = m_data->GetPixels();
|
||||
}
|
||||
|
||||
// go to the given position
|
||||
void MoveTo(int x, int y)
|
||||
{
|
||||
Reset();
|
||||
Offset(x, y);
|
||||
}
|
||||
|
||||
// same as OffsetX(1) for convenience
|
||||
wxRawBitmapIterator& operator++()
|
||||
{
|
||||
OffsetX(1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// postfix (hence less efficient) version
|
||||
wxRawBitmapIterator operator++(int)
|
||||
{
|
||||
wxRawBitmapIterator p(*this);
|
||||
OffsetX(1);
|
||||
return p;
|
||||
}
|
||||
|
||||
// data access
|
||||
// -----------
|
||||
|
||||
// DIBs store data in BGR format, i.e. "little endian" RGB
|
||||
enum
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
BLUE, GREEN, RED,
|
||||
#else // !__WXMSW__
|
||||
RED, GREEN, BLUE,
|
||||
#endif // __WXMSW__/!__WXMSW__
|
||||
ALPHA
|
||||
};
|
||||
|
||||
// access to invidividual colour components
|
||||
unsigned char& Red() { return m_ptr[RED]; }
|
||||
unsigned char& Green() { return m_ptr[GREEN]; }
|
||||
unsigned char& Blue() { return m_ptr[BLUE]; }
|
||||
unsigned char& Alpha() { return m_ptr[ALPHA]; }
|
||||
|
||||
// address the pixel contents directly
|
||||
//
|
||||
// warning: the format is platform dependent
|
||||
wxUint32& Data() { return *(wxUint32 *)m_ptr; }
|
||||
|
||||
// private: -- don't access these fields directly, same as as above
|
||||
unsigned char *m_ptr;
|
||||
|
||||
const wxRawBitmapData *m_data;
|
||||
};
|
||||
|
||||
|
||||
// these macros are used to change the current location in the bitmap
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// move x pixels to the right and y down
|
||||
//
|
||||
// note that the rows don't wrap!
|
||||
#define wxBMP_OFFSET(p, x, y) \
|
||||
p.m_ptr += p.m_data->m_stride * (y) + p.m_data->m_bypp * (x)
|
||||
|
||||
// move x pixels to the right (again, no row wrapping)
|
||||
#define wxBMP_OFFSET_X(p, x) p.m_ptr += p.m_data->m_bypp * (x)
|
||||
|
||||
// move y rows to the bottom
|
||||
#define wxBMP_OFFSET_Y(p, y) p.m_ptr += p.m_data->m_stride * (y)
|
||||
|
||||
|
||||
|
||||
// these macros are used to work with the pixel values
|
||||
//
|
||||
// all of them can be used as either lvalues or rvalues.
|
||||
// ----------------------------------------------------
|
||||
|
||||
#define wxBMP_RED(p) (p.m_ptr[wxRawBitmapIterator::RED])
|
||||
#define wxBMP_GREEN(p) (p.m_ptr[wxRawBitmapIterator::GREEN])
|
||||
#define wxBMP_BLUE(p) (p.m_ptr[wxRawBitmapIterator::BLUE])
|
||||
|
||||
#define wxBMP_ALPHA(p) (p.m_ptr[wxRawBitmapIterator::ALPHA])
|
||||
|
||||
// these macros are most efficient but return the buffer contents in
|
||||
// platform-specific format, e.g. RGB on all sane platforms and BGR under Win32
|
||||
#define wxBMP_RGB(p) *(wxUint32 *)(p.m_ptr)
|
||||
#define wxBMP_RGBA(p) *(wxUint32 *)(p.m_ptr)
|
||||
|
||||
#endif // _WX_RAWBMP_H_BASE_
|
||||
|
1704
src/msw/bitmap.cpp
Normal file
1704
src/msw/bitmap.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2356
src/msw/dc.cpp
Normal file
2356
src/msw/dc.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user