]>
Commit | Line | Data |
---|---|---|
1 | //////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/palmos/bitmap.cpp | |
3 | // Purpose: wxBitmap | |
4 | // Author: William Osborne - minimal working wxPalmOS port | |
5 | // Modified by: | |
6 | // Created: 10/08/04 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) William Osborne | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #include "wx/bitmap.h" | |
28 | ||
29 | #ifndef WX_PRECOMP | |
30 | #include <stdio.h> | |
31 | ||
32 | #include "wx/list.h" | |
33 | #include "wx/utils.h" | |
34 | #include "wx/app.h" | |
35 | #include "wx/palette.h" | |
36 | #include "wx/dcmemory.h" | |
37 | #include "wx/icon.h" | |
38 | #include "wx/log.h" | |
39 | #include "wx/image.h" | |
40 | #endif | |
41 | ||
42 | #if wxUSE_WXDIB | |
43 | #include "wx/palmos/dib.h" | |
44 | #endif | |
45 | ||
46 | #include "wx/xpmdecod.h" | |
47 | ||
48 | // missing from mingw32 header | |
49 | #ifndef CLR_INVALID | |
50 | #define CLR_INVALID ((COLORREF)-1) | |
51 | #endif // no CLR_INVALID | |
52 | ||
53 | // ---------------------------------------------------------------------------- | |
54 | // Bitmap data | |
55 | // ---------------------------------------------------------------------------- | |
56 | ||
57 | class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData | |
58 | { | |
59 | public: | |
60 | wxBitmapRefData(); | |
61 | virtual ~wxBitmapRefData() { Free(); } | |
62 | ||
63 | virtual void Free(); | |
64 | ||
65 | // set the mask object to use as the mask, we take ownership of it | |
66 | void SetMask(wxMask *mask) | |
67 | { | |
68 | delete m_bitmapMask; | |
69 | m_bitmapMask = mask; | |
70 | } | |
71 | ||
72 | // return the mask | |
73 | wxMask *GetMask() const { return m_bitmapMask; } | |
74 | ||
75 | public: | |
76 | #if wxUSE_PALETTE | |
77 | wxPalette m_bitmapPalette; | |
78 | #endif // wxUSE_PALETTE | |
79 | ||
80 | #if wxUSE_WXDIB | |
81 | wxDIB *m_dib; | |
82 | #endif | |
83 | ||
84 | bool m_hasAlpha; | |
85 | ||
86 | bool m_isDIB; | |
87 | ||
88 | private: | |
89 | wxMask *m_bitmapMask; | |
90 | ||
91 | wxDECLARE_NO_COPY_CLASS(wxBitmapRefData); | |
92 | }; | |
93 | ||
94 | // ---------------------------------------------------------------------------- | |
95 | // macros | |
96 | // ---------------------------------------------------------------------------- | |
97 | ||
98 | IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) | |
99 | IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) | |
100 | ||
101 | IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject) | |
102 | ||
103 | // ============================================================================ | |
104 | // implementation | |
105 | // ============================================================================ | |
106 | ||
107 | // ---------------------------------------------------------------------------- | |
108 | // helper functions | |
109 | // ---------------------------------------------------------------------------- | |
110 | ||
111 | #if !wxUSE_WXDIB | |
112 | #define NEVER_USE_DIB | |
113 | #else | |
114 | static inline bool wxShouldCreateDIB(int w, int h, int d, WXHDC hdc) | |
115 | { | |
116 | // here is the logic: | |
117 | // | |
118 | // (a) if hdc is specified, the caller explicitly wants DDB | |
119 | // (b) otherwise, create a DIB if depth >= 24 (we don't support 16bpp | |
120 | // or less DIBs anyhow) | |
121 | // (c) finally, create DIBs under Win9x even if the depth hasn't been | |
122 | // explicitly specified but the current display depth is 24 or | |
123 | // more and the image is "big", i.e. > 16Mb which is the | |
124 | // theoretical limit for DDBs under Win9x | |
125 | // | |
126 | // consequences (all of which seem to make sense): | |
127 | // | |
128 | // (i) by default, DDBs are created (depth == -1 usually) | |
129 | // (ii) DIBs can be created by explicitly specifying the depth | |
130 | // (iii) using a DC always forces creating a DDB | |
131 | return !hdc && | |
132 | (d >= 24 || | |
133 | (d == -1 && | |
134 | wxDIB::GetLineSize(w, wxDisplayDepth())*h > 16*1024*1024)); | |
135 | } | |
136 | ||
137 | #define SOMETIMES_USE_DIB | |
138 | #endif // different DIB usage scenarious | |
139 | ||
140 | // ---------------------------------------------------------------------------- | |
141 | // wxBitmapRefData | |
142 | // ---------------------------------------------------------------------------- | |
143 | ||
144 | wxBitmapRefData::wxBitmapRefData() | |
145 | { | |
146 | m_bitmapMask = NULL; | |
147 | ||
148 | m_hBitmap = (WXHBITMAP) NULL; | |
149 | #if wxUSE_WXDIB | |
150 | m_dib = NULL; | |
151 | #endif | |
152 | ||
153 | m_isDIB = | |
154 | m_hasAlpha = false; | |
155 | } | |
156 | ||
157 | void wxBitmapRefData::Free() | |
158 | { | |
159 | } | |
160 | ||
161 | // ---------------------------------------------------------------------------- | |
162 | // wxBitmap creation | |
163 | // ---------------------------------------------------------------------------- | |
164 | ||
165 | // this function should be called from all wxBitmap ctors | |
166 | void wxBitmap::Init() | |
167 | { | |
168 | } | |
169 | ||
170 | wxGDIImageRefData *wxBitmap::CreateData() const | |
171 | { | |
172 | return NULL; | |
173 | } | |
174 | ||
175 | bool wxBitmap::CopyFromCursor(const wxCursor& cursor) | |
176 | { | |
177 | return false; | |
178 | } | |
179 | ||
180 | bool wxBitmap::CopyFromIcon(const wxIcon& icon) | |
181 | { | |
182 | return false; | |
183 | } | |
184 | ||
185 | #ifndef NEVER_USE_DIB | |
186 | ||
187 | bool wxBitmap::CopyFromDIB(const wxDIB& dib) | |
188 | { | |
189 | return false: | |
190 | } | |
191 | ||
192 | #endif // NEVER_USE_DIB | |
193 | ||
194 | wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) | |
195 | { | |
196 | Init(); | |
197 | } | |
198 | ||
199 | wxBitmap::wxBitmap(int w, int h, const wxDC& dc) | |
200 | { | |
201 | } | |
202 | ||
203 | wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth) | |
204 | { | |
205 | } | |
206 | ||
207 | wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) | |
208 | { | |
209 | } | |
210 | ||
211 | bool wxBitmap::Create(int width, int height, int depth) | |
212 | { | |
213 | return false; | |
214 | } | |
215 | ||
216 | bool wxBitmap::Create(int width, int height, const wxDC& dc) | |
217 | { | |
218 | return false; | |
219 | } | |
220 | ||
221 | bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) | |
222 | { | |
223 | return false; | |
224 | } | |
225 | ||
226 | #if wxUSE_IMAGE | |
227 | ||
228 | // ---------------------------------------------------------------------------- | |
229 | // wxImage to/from conversions | |
230 | // ---------------------------------------------------------------------------- | |
231 | ||
232 | #if wxUSE_WXDIB | |
233 | ||
234 | bool wxBitmap::CreateFromImage(const wxImage& image, int depth) | |
235 | { | |
236 | return false; | |
237 | } | |
238 | ||
239 | bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc) | |
240 | { | |
241 | return false; | |
242 | } | |
243 | ||
244 | bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) | |
245 | { | |
246 | return false; | |
247 | } | |
248 | ||
249 | wxImage wxBitmap::ConvertToImage() const | |
250 | { | |
251 | wxImage image; | |
252 | return image; | |
253 | } | |
254 | ||
255 | #endif // wxUSE_WXDIB | |
256 | ||
257 | #endif // wxUSE_IMAGE | |
258 | ||
259 | // ---------------------------------------------------------------------------- | |
260 | // loading and saving bitmaps | |
261 | // ---------------------------------------------------------------------------- | |
262 | ||
263 | bool wxBitmap::LoadFile(const wxString& filename, long type) | |
264 | { | |
265 | return false; | |
266 | } | |
267 | ||
268 | bool wxBitmap::Create(const void* data, long type, int width, int height, int depth) | |
269 | { | |
270 | return false; | |
271 | } | |
272 | ||
273 | bool wxBitmap::SaveFile(const wxString& filename, | |
274 | int type, | |
275 | const wxPalette *palette) | |
276 | { | |
277 | return false; | |
278 | } | |
279 | ||
280 | // ---------------------------------------------------------------------------- | |
281 | // sub bitmap extraction | |
282 | // ---------------------------------------------------------------------------- | |
283 | ||
284 | wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const | |
285 | { | |
286 | wxBitmap ret( 0, 0 ); | |
287 | return ret; | |
288 | } | |
289 | ||
290 | // ---------------------------------------------------------------------------- | |
291 | // wxBitmap accessors | |
292 | // ---------------------------------------------------------------------------- | |
293 | ||
294 | #if wxUSE_PALETTE | |
295 | wxPalette* wxBitmap::GetPalette() const | |
296 | { | |
297 | return NULL; | |
298 | } | |
299 | #endif | |
300 | ||
301 | wxMask *wxBitmap::GetMask() const | |
302 | { | |
303 | return NULL; | |
304 | } | |
305 | ||
306 | bool wxBitmap::HasAlpha() const | |
307 | { | |
308 | return false; | |
309 | } | |
310 | ||
311 | // ---------------------------------------------------------------------------- | |
312 | // wxBitmap setters | |
313 | // ---------------------------------------------------------------------------- | |
314 | ||
315 | #if wxUSE_PALETTE | |
316 | ||
317 | void wxBitmap::SetPalette(const wxPalette& palette) | |
318 | { | |
319 | } | |
320 | ||
321 | #endif // wxUSE_PALETTE | |
322 | ||
323 | void wxBitmap::SetMask(wxMask *mask) | |
324 | { | |
325 | } | |
326 | ||
327 | // ---------------------------------------------------------------------------- | |
328 | // raw bitmap access support | |
329 | // ---------------------------------------------------------------------------- | |
330 | ||
331 | // ---------------------------------------------------------------------------- | |
332 | // wxMask | |
333 | // ---------------------------------------------------------------------------- | |
334 | ||
335 | wxMask::wxMask() | |
336 | { | |
337 | m_maskBitmap = 0; | |
338 | } | |
339 | ||
340 | // Construct a mask from a bitmap and a colour indicating | |
341 | // the transparent area | |
342 | wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) | |
343 | { | |
344 | } | |
345 | ||
346 | // Construct a mask from a bitmap and a palette index indicating | |
347 | // the transparent area | |
348 | wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) | |
349 | { | |
350 | } | |
351 | ||
352 | // Construct a mask from a mono bitmap (copies the bitmap). | |
353 | wxMask::wxMask(const wxBitmap& bitmap) | |
354 | { | |
355 | } | |
356 | ||
357 | wxMask::~wxMask() | |
358 | { | |
359 | } | |
360 | ||
361 | // Create a mask from a mono bitmap (copies the bitmap). | |
362 | bool wxMask::Create(const wxBitmap& bitmap) | |
363 | { | |
364 | return false; | |
365 | } | |
366 | ||
367 | // Create a mask from a bitmap and a palette index indicating | |
368 | // the transparent area | |
369 | bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) | |
370 | { | |
371 | return false; | |
372 | } | |
373 | ||
374 | // Create a mask from a bitmap and a colour indicating | |
375 | // the transparent area | |
376 | bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) | |
377 | { | |
378 | return false; | |
379 | } | |
380 | ||
381 | // ---------------------------------------------------------------------------- | |
382 | // wxBitmapHandler | |
383 | // ---------------------------------------------------------------------------- | |
384 | ||
385 | bool wxBitmapHandler::Create(wxGDIImage *image, | |
386 | const void* data, | |
387 | long flags, | |
388 | int width, int height, int depth) | |
389 | { | |
390 | return false; | |
391 | } | |
392 | ||
393 | bool wxBitmapHandler::Load(wxGDIImage *image, | |
394 | const wxString& name, | |
395 | long flags, | |
396 | int width, int height) | |
397 | { | |
398 | return false; | |
399 | } | |
400 | ||
401 | bool wxBitmapHandler::Save(wxGDIImage *image, | |
402 | const wxString& name, | |
403 | int type) | |
404 | { | |
405 | return false; | |
406 | } | |
407 | ||
408 | bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), | |
409 | const void* WXUNUSED(data), | |
410 | long WXUNUSED(type), | |
411 | int WXUNUSED(width), | |
412 | int WXUNUSED(height), | |
413 | int WXUNUSED(depth)) | |
414 | { | |
415 | return false; | |
416 | } | |
417 | ||
418 | bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), | |
419 | const wxString& WXUNUSED(name), | |
420 | long WXUNUSED(type), | |
421 | int WXUNUSED(desiredWidth), | |
422 | int WXUNUSED(desiredHeight)) | |
423 | { | |
424 | return false; | |
425 | } | |
426 | ||
427 | bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), | |
428 | const wxString& WXUNUSED(name), | |
429 | int WXUNUSED(type), | |
430 | const wxPalette *WXUNUSED(palette)) | |
431 | { | |
432 | return false; | |
433 | } |