// Author: Julian Smart
// Modified by:
// Created: 01/02/97
-// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#define _WX_BITMAP_H_
#include "wx/msw/gdiimage.h"
+#include "wx/math.h"
#include "wx/palette.h"
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxDIB;
#endif
class WXDLLIMPEXP_FWD_CORE wxIcon;
-class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxMask;
class WXDLLIMPEXP_FWD_CORE wxPalette;
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
// NOTE: for wxMSW we don't use the wxBitmapBase base class declared in bitmap.h!
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxBitmap : public wxGDIImage
+class WXDLLIMPEXP_CORE wxBitmap : public wxGDIImage,
+ public wxBitmapHelpers
{
public:
// default ctor creates an invalid bitmap, you must Create() it later
#ifdef wxNEEDS_CHARPP
wxBitmap(char** data)
{
- *this = wxBitmap(wx_const_cast(const char* const*, data));
+ *this = wxBitmap(const_cast<const char* const*>(data));
}
#endif
//
// 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);
+ wxBitmap(int width, int height, int depth = -1) { (void)Create(width, height, depth); }
+ wxBitmap(const wxSize& sz, int depth = -1) { (void)Create(sz, depth); }
// Create a bitmap compatible with the given DC
wxBitmap(int width, int height, const wxDC& dc);
#if wxUSE_IMAGE
wxImage ConvertToImage() const;
+ wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
#endif // wxUSE_IMAGE
// get the given part of bitmap
#endif
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
+ virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
+ { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
+
virtual bool Create(int width, int height, const wxDC& dc);
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
+ virtual bool CreateScaled(int w, int h, int d, double logicalScale)
+ { return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); }
+
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
#endif // wxUSE_PALETTE
wxMask *GetMask() const;
- wxBitmap GetMaskBitmap() const;
void SetMask(wxMask *mask);
// these functions are internal and shouldn't be used, they risk to
bool HasAlpha() const;
void UseAlpha();
+ // support for scaled bitmaps
+ virtual double GetScaleFactor() const { return 1.0; }
+ virtual double GetScaledWidth() const { return GetWidth() / GetScaleFactor(); }
+ virtual double GetScaledHeight() const { return GetHeight() / GetScaleFactor(); }
+ virtual wxSize GetScaledSize() const
+ { return wxSize(wxRound(GetScaledWidth()), wxRound(GetScaledHeight())); }
+
// implementation only from now on
// -------------------------------
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:
virtual wxGDIImageRefData *CreateData() const;
bool Create(const wxBitmap& bitmap, int paletteIndex);
bool Create(const wxBitmap& bitmap);
+ wxBitmap GetBitmap() const;
+
// Implementation
WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }