]>
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 | bool wxBitmap::HasAlpha() const | |
335 | { | |
336 | return false; | |
337 | } | |
338 | ||
339 | // ---------------------------------------------------------------------------- | |
340 | // wxBitmap setters | |
341 | // ---------------------------------------------------------------------------- | |
342 | ||
343 | #ifdef __WXDEBUG__ | |
344 | ||
345 | void wxBitmap::SetSelectedInto(wxDC *dc) | |
346 | { | |
347 | } | |
348 | ||
349 | #endif | |
350 | ||
351 | #if wxUSE_PALETTE | |
352 | ||
353 | void wxBitmap::SetPalette(const wxPalette& palette) | |
354 | { | |
355 | } | |
356 | ||
357 | #endif // wxUSE_PALETTE | |
358 | ||
359 | void wxBitmap::SetMask(wxMask *mask) | |
360 | { | |
361 | } | |
362 | ||
363 | // ---------------------------------------------------------------------------- | |
364 | // raw bitmap access support | |
365 | // ---------------------------------------------------------------------------- | |
366 | ||
367 | #ifdef wxHAVE_RAW_BITMAP | |
368 | void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) | |
369 | { | |
370 | return NULL; | |
371 | } | |
372 | ||
373 | void wxBitmap::UngetRawData(wxPixelDataBase& dataBase) | |
374 | { | |
375 | return; | |
376 | } | |
377 | #endif // #ifdef wxHAVE_RAW_BITMAP | |
378 | ||
379 | // ---------------------------------------------------------------------------- | |
380 | // wxMask | |
381 | // ---------------------------------------------------------------------------- | |
382 | ||
383 | wxMask::wxMask() | |
384 | { | |
385 | m_maskBitmap = 0; | |
386 | } | |
387 | ||
388 | // Construct a mask from a bitmap and a colour indicating | |
389 | // the transparent area | |
390 | wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) | |
391 | { | |
392 | } | |
393 | ||
394 | // Construct a mask from a bitmap and a palette index indicating | |
395 | // the transparent area | |
396 | wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) | |
397 | { | |
398 | } | |
399 | ||
400 | // Construct a mask from a mono bitmap (copies the bitmap). | |
401 | wxMask::wxMask(const wxBitmap& bitmap) | |
402 | { | |
403 | } | |
404 | ||
405 | wxMask::~wxMask() | |
406 | { | |
407 | } | |
408 | ||
409 | // Create a mask from a mono bitmap (copies the bitmap). | |
410 | bool wxMask::Create(const wxBitmap& bitmap) | |
411 | { | |
412 | return false; | |
413 | } | |
414 | ||
415 | // Create a mask from a bitmap and a palette index indicating | |
416 | // the transparent area | |
417 | bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) | |
418 | { | |
419 | return false; | |
420 | } | |
421 | ||
422 | // Create a mask from a bitmap and a colour indicating | |
423 | // the transparent area | |
424 | bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) | |
425 | { | |
426 | return false; | |
427 | } | |
428 | ||
429 | // ---------------------------------------------------------------------------- | |
430 | // wxBitmapHandler | |
431 | // ---------------------------------------------------------------------------- | |
432 | ||
433 | bool wxBitmapHandler::Create(wxGDIImage *image, | |
434 | const void* data, | |
435 | long flags, | |
436 | int width, int height, int depth) | |
437 | { | |
438 | return false; | |
439 | } | |
440 | ||
441 | bool wxBitmapHandler::Load(wxGDIImage *image, | |
442 | const wxString& name, | |
443 | long flags, | |
444 | int width, int height) | |
445 | { | |
446 | return false; | |
447 | } | |
448 | ||
449 | bool wxBitmapHandler::Save(wxGDIImage *image, | |
450 | const wxString& name, | |
451 | int type) | |
452 | { | |
453 | return false; | |
454 | } | |
455 | ||
456 | bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), | |
457 | const void* WXUNUSED(data), | |
458 | long WXUNUSED(type), | |
459 | int WXUNUSED(width), | |
460 | int WXUNUSED(height), | |
461 | int WXUNUSED(depth)) | |
462 | { | |
463 | return false; | |
464 | } | |
465 | ||
466 | bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), | |
467 | const wxString& WXUNUSED(name), | |
468 | long WXUNUSED(type), | |
469 | int WXUNUSED(desiredWidth), | |
470 | int WXUNUSED(desiredHeight)) | |
471 | { | |
472 | return false; | |
473 | } | |
474 | ||
475 | bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), | |
476 | const wxString& WXUNUSED(name), | |
477 | int WXUNUSED(type), | |
478 | const wxPalette *WXUNUSED(palette)) | |
479 | { | |
480 | return false; | |
481 | } |