]>
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 | #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 = | |
165 | m_hasAlpha = false; | |
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 | ||
186 | bool wxBitmap::CopyFromCursor(const wxCursor& cursor) | |
187 | { | |
188 | return false; | |
189 | } | |
190 | ||
191 | bool wxBitmap::CopyFromIcon(const wxIcon& icon) | |
192 | { | |
193 | return false; | |
194 | } | |
195 | ||
196 | #ifndef NEVER_USE_DIB | |
197 | ||
198 | bool wxBitmap::CopyFromDIB(const wxDIB& dib) | |
199 | { | |
200 | return false: | |
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 | wxBitmap::wxBitmap(int w, int h, int d) | |
215 | { | |
216 | } | |
217 | ||
218 | wxBitmap::wxBitmap(int w, int h, const wxDC& dc) | |
219 | { | |
220 | } | |
221 | ||
222 | wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth) | |
223 | { | |
224 | } | |
225 | ||
226 | wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) | |
227 | { | |
228 | } | |
229 | ||
230 | bool wxBitmap::Create(int width, int height, int depth) | |
231 | { | |
232 | return false; | |
233 | } | |
234 | ||
235 | bool wxBitmap::Create(int width, int height, const wxDC& dc) | |
236 | { | |
237 | return false; | |
238 | } | |
239 | ||
240 | bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) | |
241 | { | |
242 | return false; | |
243 | } | |
244 | ||
245 | #if wxUSE_IMAGE | |
246 | ||
247 | // ---------------------------------------------------------------------------- | |
248 | // wxImage to/from conversions | |
249 | // ---------------------------------------------------------------------------- | |
250 | ||
251 | #if wxUSE_WXDIB | |
252 | ||
253 | bool wxBitmap::CreateFromImage(const wxImage& image, int depth) | |
254 | { | |
255 | return false; | |
256 | } | |
257 | ||
258 | bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc) | |
259 | { | |
260 | return false; | |
261 | } | |
262 | ||
263 | bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) | |
264 | { | |
265 | return false; | |
266 | } | |
267 | ||
268 | wxImage wxBitmap::ConvertToImage() const | |
269 | { | |
270 | wxImage image; | |
271 | return image; | |
272 | } | |
273 | ||
274 | #endif // wxUSE_WXDIB | |
275 | ||
276 | #endif // wxUSE_IMAGE | |
277 | ||
278 | // ---------------------------------------------------------------------------- | |
279 | // loading and saving bitmaps | |
280 | // ---------------------------------------------------------------------------- | |
281 | ||
282 | bool wxBitmap::LoadFile(const wxString& filename, long type) | |
283 | { | |
284 | return false; | |
285 | } | |
286 | ||
287 | bool wxBitmap::Create(const void* data, long type, int width, int height, int depth) | |
288 | { | |
289 | return false; | |
290 | } | |
291 | ||
292 | bool wxBitmap::SaveFile(const wxString& filename, | |
293 | int type, | |
294 | const wxPalette *palette) | |
295 | { | |
296 | return false; | |
297 | } | |
298 | ||
299 | // ---------------------------------------------------------------------------- | |
300 | // sub bitmap extraction | |
301 | // ---------------------------------------------------------------------------- | |
302 | ||
303 | wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const | |
304 | { | |
305 | wxBitmap ret( 0, 0 ); | |
306 | return ret; | |
307 | } | |
308 | ||
309 | // ---------------------------------------------------------------------------- | |
310 | // wxBitmap accessors | |
311 | // ---------------------------------------------------------------------------- | |
312 | ||
313 | #if wxUSE_PALETTE | |
314 | wxPalette* wxBitmap::GetPalette() const | |
315 | { | |
316 | return (wxPalette *) NULL; | |
317 | } | |
318 | #endif | |
319 | ||
320 | wxMask *wxBitmap::GetMask() const | |
321 | { | |
322 | return (wxMask *) NULL; | |
323 | } | |
324 | ||
325 | #ifdef __WXDEBUG__ | |
326 | ||
327 | wxDC *wxBitmap::GetSelectedInto() const | |
328 | { | |
329 | return (wxDC *) NULL; | |
330 | } | |
331 | ||
332 | #endif | |
333 | ||
334 | void wxBitmap::UseAlpha() | |
335 | { | |
336 | } | |
337 | ||
338 | bool wxBitmap::HasAlpha() const | |
339 | { | |
340 | return false; | |
341 | } | |
342 | ||
343 | // ---------------------------------------------------------------------------- | |
344 | // wxBitmap setters | |
345 | // ---------------------------------------------------------------------------- | |
346 | ||
347 | #ifdef __WXDEBUG__ | |
348 | ||
349 | void wxBitmap::SetSelectedInto(wxDC *dc) | |
350 | { | |
351 | } | |
352 | ||
353 | #endif | |
354 | ||
355 | #if wxUSE_PALETTE | |
356 | ||
357 | void wxBitmap::SetPalette(const wxPalette& palette) | |
358 | { | |
359 | } | |
360 | ||
361 | #endif // wxUSE_PALETTE | |
362 | ||
363 | void wxBitmap::SetMask(wxMask *mask) | |
364 | { | |
365 | } | |
366 | ||
367 | // ---------------------------------------------------------------------------- | |
368 | // raw bitmap access support | |
369 | // ---------------------------------------------------------------------------- | |
370 | ||
371 | #ifdef wxHAVE_RAW_BITMAP | |
372 | void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) | |
373 | { | |
374 | return NULL; | |
375 | } | |
376 | ||
377 | void wxBitmap::UngetRawData(wxPixelDataBase& dataBase) | |
378 | { | |
379 | return; | |
380 | } | |
381 | #endif // #ifdef wxHAVE_RAW_BITMAP | |
382 | ||
383 | // ---------------------------------------------------------------------------- | |
384 | // wxMask | |
385 | // ---------------------------------------------------------------------------- | |
386 | ||
387 | wxMask::wxMask() | |
388 | { | |
389 | m_maskBitmap = 0; | |
390 | } | |
391 | ||
392 | // Construct a mask from a bitmap and a colour indicating | |
393 | // the transparent area | |
394 | wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) | |
395 | { | |
396 | } | |
397 | ||
398 | // Construct a mask from a bitmap and a palette index indicating | |
399 | // the transparent area | |
400 | wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) | |
401 | { | |
402 | } | |
403 | ||
404 | // Construct a mask from a mono bitmap (copies the bitmap). | |
405 | wxMask::wxMask(const wxBitmap& bitmap) | |
406 | { | |
407 | } | |
408 | ||
409 | wxMask::~wxMask() | |
410 | { | |
411 | } | |
412 | ||
413 | // Create a mask from a mono bitmap (copies the bitmap). | |
414 | bool wxMask::Create(const wxBitmap& bitmap) | |
415 | { | |
416 | return false; | |
417 | } | |
418 | ||
419 | // Create a mask from a bitmap and a palette index indicating | |
420 | // the transparent area | |
421 | bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) | |
422 | { | |
423 | return false; | |
424 | } | |
425 | ||
426 | // Create a mask from a bitmap and a colour indicating | |
427 | // the transparent area | |
428 | bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) | |
429 | { | |
430 | return false; | |
431 | } | |
432 | ||
433 | // ---------------------------------------------------------------------------- | |
434 | // wxBitmapHandler | |
435 | // ---------------------------------------------------------------------------- | |
436 | ||
437 | bool wxBitmapHandler::Create(wxGDIImage *image, | |
438 | const void* data, | |
439 | long flags, | |
440 | int width, int height, int depth) | |
441 | { | |
442 | return false; | |
443 | } | |
444 | ||
445 | bool wxBitmapHandler::Load(wxGDIImage *image, | |
446 | const wxString& name, | |
447 | long flags, | |
448 | int width, int height) | |
449 | { | |
450 | return false; | |
451 | } | |
452 | ||
453 | bool wxBitmapHandler::Save(wxGDIImage *image, | |
454 | const wxString& name, | |
455 | int type) | |
456 | { | |
457 | return false; | |
458 | } | |
459 | ||
460 | bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), | |
461 | const void* WXUNUSED(data), | |
462 | long WXUNUSED(type), | |
463 | int WXUNUSED(width), | |
464 | int WXUNUSED(height), | |
465 | int WXUNUSED(depth)) | |
466 | { | |
467 | return false; | |
468 | } | |
469 | ||
470 | bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), | |
471 | const wxString& WXUNUSED(name), | |
472 | long WXUNUSED(type), | |
473 | int WXUNUSED(desiredWidth), | |
474 | int WXUNUSED(desiredHeight)) | |
475 | { | |
476 | return false; | |
477 | } | |
478 | ||
479 | bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), | |
480 | const wxString& WXUNUSED(name), | |
481 | int WXUNUSED(type), | |
482 | const wxPalette *WXUNUSED(palette)) | |
483 | { | |
484 | return false; | |
485 | } |