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