]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/dib.cpp
3319054f5e9c26da82919402f73b586fad904a36
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/dib.cpp
3 // Purpose: implements wxDIB class
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
30 #include "wx/string.h"
33 #include "wx/bitmap.h"
39 #include "wx/palmos/dib.h"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 // calculate the number of palette entries needed for the bitmap with this
46 // number of bits per pixel
47 static inline WORD
GetNumberOfColours(WORD bitsPerPixel
)
49 // only 1, 4 and 8bpp bitmaps use palettes (well, they could be used with
50 // 24bpp ones too but we don't support this as I think it's quite uncommon)
51 return bitsPerPixel
<= 8 ? 1 << bitsPerPixel
: 0;
54 // wrapper around ::GetObject() for DIB sections
55 static inline bool GetDIBSection(HBITMAP hbmp
, DIBSECTION
*ds
)
57 // note that at least under Win9x (this doesn't seem to happen under Win2K
58 // but this doesn't mean anything, of course), GetObject() may return
59 // sizeof(DIBSECTION) for a bitmap which is *not* a DIB section and the way
60 // to check for it is by looking at the bits pointer
61 return ::GetObject(hbmp
, sizeof(DIBSECTION
), ds
) == sizeof(DIBSECTION
) &&
65 // ============================================================================
67 // ============================================================================
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 bool wxDIB::Create(int width
, int height
, int depth
)
78 bool wxDIB::Create(const wxBitmap
& bmp
)
83 bool wxDIB::CopyFromDDB(HBITMAP hbmp
)
89 // ----------------------------------------------------------------------------
90 // Loading/saving the DIBs
91 // ----------------------------------------------------------------------------
93 bool wxDIB::Load(const wxString
& filename
)
98 bool wxDIB::Save(const wxString
& filename
)
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 void wxDIB::DoGetObject() const
111 // ----------------------------------------------------------------------------
112 // DDB <-> DIB conversions
113 // ----------------------------------------------------------------------------
115 HBITMAP
wxDIB::CreateDDB(HDC hdc
) const
121 HBITMAP
wxDIB::ConvertToBitmap(const BITMAPINFO
*pbmi
, HDC hdc
, void *bits
)
127 size_t wxDIB::ConvertFromBitmap(BITMAPINFO
*pbi
, HBITMAP hbmp
)
133 HGLOBAL
wxDIB::ConvertFromBitmap(HBITMAP hbmp
)
138 // ----------------------------------------------------------------------------
140 // ----------------------------------------------------------------------------
144 wxPalette
*wxDIB::CreatePalette() const
149 #endif // wxUSE_PALETTE
151 // ----------------------------------------------------------------------------
153 // ----------------------------------------------------------------------------
157 bool wxDIB::Create(const wxImage
& image
)
162 wxImage
wxDIB::ConvertToImage() const
167 #endif // wxUSE_IMAGE
169 #endif // wxUSE_WXDIB