]>
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" |
155ecd4c | 39 | #include "wx/image.h" |
ffecfa5a JS |
40 | #endif |
41 | ||
ffecfa5a JS |
42 | #if wxUSE_WXDIB |
43 | #include "wx/palmos/dib.h" | |
44 | #endif | |
45 | ||
ffecfa5a JS |
46 | #include "wx/xpmdecod.h" |
47 | ||
ffecfa5a JS |
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 | #ifdef __WXDEBUG__ | |
81 | wxDC *m_selectedInto; | |
82 | #endif // __WXDEBUG__ | |
83 | ||
84 | #if wxUSE_WXDIB | |
85 | wxDIB *m_dib; | |
86 | #endif | |
87 | ||
88 | bool m_hasAlpha; | |
89 | ||
90 | bool m_isDIB; | |
91 | ||
92 | private: | |
93 | wxMask *m_bitmapMask; | |
94 | ||
c0c133e1 | 95 | wxDECLARE_NO_COPY_CLASS(wxBitmapRefData); |
ffecfa5a JS |
96 | }; |
97 | ||
98 | // ---------------------------------------------------------------------------- | |
99 | // macros | |
100 | // ---------------------------------------------------------------------------- | |
101 | ||
102 | IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) | |
103 | IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) | |
104 | ||
105 | IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject) | |
106 | ||
107 | // ============================================================================ | |
108 | // implementation | |
109 | // ============================================================================ | |
110 | ||
111 | // ---------------------------------------------------------------------------- | |
112 | // helper functions | |
113 | // ---------------------------------------------------------------------------- | |
114 | ||
115 | #if !wxUSE_WXDIB | |
116 | #define NEVER_USE_DIB | |
117 | #else | |
118 | static inline bool wxShouldCreateDIB(int w, int h, int d, WXHDC hdc) | |
119 | { | |
120 | // here is the logic: | |
121 | // | |
122 | // (a) if hdc is specified, the caller explicitly wants DDB | |
123 | // (b) otherwise, create a DIB if depth >= 24 (we don't support 16bpp | |
124 | // or less DIBs anyhow) | |
125 | // (c) finally, create DIBs under Win9x even if the depth hasn't been | |
126 | // explicitly specified but the current display depth is 24 or | |
127 | // more and the image is "big", i.e. > 16Mb which is the | |
128 | // theoretical limit for DDBs under Win9x | |
129 | // | |
130 | // consequences (all of which seem to make sense): | |
131 | // | |
132 | // (i) by default, DDBs are created (depth == -1 usually) | |
133 | // (ii) DIBs can be created by explicitly specifying the depth | |
134 | // (iii) using a DC always forces creating a DDB | |
135 | return !hdc && | |
136 | (d >= 24 || | |
137 | (d == -1 && | |
138 | wxDIB::GetLineSize(w, wxDisplayDepth())*h > 16*1024*1024)); | |
139 | } | |
140 | ||
141 | #define SOMETIMES_USE_DIB | |
142 | #endif // different DIB usage scenarious | |
143 | ||
144 | // ---------------------------------------------------------------------------- | |
145 | // wxBitmapRefData | |
146 | // ---------------------------------------------------------------------------- | |
147 | ||
148 | wxBitmapRefData::wxBitmapRefData() | |
149 | { | |
150 | #ifdef __WXDEBUG__ | |
151 | m_selectedInto = NULL; | |
152 | #endif | |
153 | m_bitmapMask = NULL; | |
154 | ||
155 | m_hBitmap = (WXHBITMAP) NULL; | |
156 | #if wxUSE_WXDIB | |
157 | m_dib = NULL; | |
158 | #endif | |
159 | ||
160 | m_isDIB = | |
4055ed82 | 161 | m_hasAlpha = false; |
ffecfa5a JS |
162 | } |
163 | ||
164 | void wxBitmapRefData::Free() | |
165 | { | |
166 | } | |
167 | ||
168 | // ---------------------------------------------------------------------------- | |
169 | // wxBitmap creation | |
170 | // ---------------------------------------------------------------------------- | |
171 | ||
172 | // this function should be called from all wxBitmap ctors | |
173 | void wxBitmap::Init() | |
174 | { | |
175 | } | |
176 | ||
177 | wxGDIImageRefData *wxBitmap::CreateData() const | |
178 | { | |
179 | return NULL; | |
180 | } | |
181 | ||
ffecfa5a JS |
182 | bool wxBitmap::CopyFromCursor(const wxCursor& cursor) |
183 | { | |
4055ed82 | 184 | return false; |
ffecfa5a JS |
185 | } |
186 | ||
187 | bool wxBitmap::CopyFromIcon(const wxIcon& icon) | |
188 | { | |
4055ed82 | 189 | return false; |
ffecfa5a JS |
190 | } |
191 | ||
192 | #ifndef NEVER_USE_DIB | |
193 | ||
194 | bool wxBitmap::CopyFromDIB(const wxDIB& dib) | |
195 | { | |
4055ed82 | 196 | return false: |
ffecfa5a JS |
197 | } |
198 | ||
199 | #endif // NEVER_USE_DIB | |
200 | ||
201 | wxBitmap::~wxBitmap() | |
202 | { | |
203 | } | |
204 | ||
205 | wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) | |
206 | { | |
207 | Init(); | |
208 | } | |
209 | ||
ffecfa5a JS |
210 | wxBitmap::wxBitmap(int w, int h, int d) |
211 | { | |
212 | } | |
213 | ||
214 | wxBitmap::wxBitmap(int w, int h, const wxDC& dc) | |
215 | { | |
216 | } | |
217 | ||
452418c4 | 218 | wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth) |
ffecfa5a JS |
219 | { |
220 | } | |
221 | ||
222 | wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) | |
223 | { | |
224 | } | |
225 | ||
226 | bool wxBitmap::Create(int width, int height, int depth) | |
227 | { | |
4055ed82 | 228 | return false; |
ffecfa5a JS |
229 | } |
230 | ||
231 | bool wxBitmap::Create(int width, int height, const wxDC& dc) | |
232 | { | |
4055ed82 | 233 | return false; |
ffecfa5a JS |
234 | } |
235 | ||
236 | bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) | |
237 | { | |
4055ed82 | 238 | return false; |
ffecfa5a JS |
239 | } |
240 | ||
241 | #if wxUSE_IMAGE | |
242 | ||
243 | // ---------------------------------------------------------------------------- | |
244 | // wxImage to/from conversions | |
245 | // ---------------------------------------------------------------------------- | |
246 | ||
247 | #if wxUSE_WXDIB | |
248 | ||
249 | bool wxBitmap::CreateFromImage(const wxImage& image, int depth) | |
250 | { | |
4055ed82 | 251 | return false; |
ffecfa5a JS |
252 | } |
253 | ||
254 | bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc) | |
255 | { | |
4055ed82 | 256 | return false; |
ffecfa5a JS |
257 | } |
258 | ||
259 | bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) | |
260 | { | |
4055ed82 | 261 | return false; |
ffecfa5a JS |
262 | } |
263 | ||
264 | wxImage wxBitmap::ConvertToImage() const | |
265 | { | |
266 | wxImage image; | |
267 | return image; | |
268 | } | |
269 | ||
270 | #endif // wxUSE_WXDIB | |
271 | ||
272 | #endif // wxUSE_IMAGE | |
273 | ||
274 | // ---------------------------------------------------------------------------- | |
275 | // loading and saving bitmaps | |
276 | // ---------------------------------------------------------------------------- | |
277 | ||
278 | bool wxBitmap::LoadFile(const wxString& filename, long type) | |
279 | { | |
4055ed82 | 280 | return false; |
ffecfa5a JS |
281 | } |
282 | ||
452418c4 | 283 | bool wxBitmap::Create(const void* data, long type, int width, int height, int depth) |
ffecfa5a | 284 | { |
4055ed82 | 285 | return false; |
ffecfa5a JS |
286 | } |
287 | ||
288 | bool wxBitmap::SaveFile(const wxString& filename, | |
289 | int type, | |
290 | const wxPalette *palette) | |
291 | { | |
4055ed82 | 292 | return false; |
ffecfa5a JS |
293 | } |
294 | ||
295 | // ---------------------------------------------------------------------------- | |
296 | // sub bitmap extraction | |
297 | // ---------------------------------------------------------------------------- | |
298 | ||
299 | wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const | |
300 | { | |
301 | wxBitmap ret( 0, 0 ); | |
302 | return ret; | |
303 | } | |
304 | ||
305 | // ---------------------------------------------------------------------------- | |
306 | // wxBitmap accessors | |
307 | // ---------------------------------------------------------------------------- | |
308 | ||
309 | #if wxUSE_PALETTE | |
310 | wxPalette* wxBitmap::GetPalette() const | |
311 | { | |
d3b9f782 | 312 | return NULL; |
ffecfa5a JS |
313 | } |
314 | #endif | |
315 | ||
316 | wxMask *wxBitmap::GetMask() const | |
317 | { | |
d3b9f782 | 318 | return NULL; |
ffecfa5a JS |
319 | } |
320 | ||
321 | #ifdef __WXDEBUG__ | |
322 | ||
323 | wxDC *wxBitmap::GetSelectedInto() const | |
324 | { | |
d3b9f782 | 325 | return NULL; |
ffecfa5a JS |
326 | } |
327 | ||
328 | #endif | |
329 | ||
ffecfa5a JS |
330 | bool wxBitmap::HasAlpha() const |
331 | { | |
4055ed82 | 332 | return false; |
ffecfa5a JS |
333 | } |
334 | ||
335 | // ---------------------------------------------------------------------------- | |
336 | // wxBitmap setters | |
337 | // ---------------------------------------------------------------------------- | |
338 | ||
339 | #ifdef __WXDEBUG__ | |
340 | ||
341 | void wxBitmap::SetSelectedInto(wxDC *dc) | |
342 | { | |
343 | } | |
344 | ||
345 | #endif | |
346 | ||
347 | #if wxUSE_PALETTE | |
348 | ||
349 | void wxBitmap::SetPalette(const wxPalette& palette) | |
350 | { | |
351 | } | |
352 | ||
353 | #endif // wxUSE_PALETTE | |
354 | ||
355 | void wxBitmap::SetMask(wxMask *mask) | |
356 | { | |
357 | } | |
358 | ||
ffecfa5a JS |
359 | // ---------------------------------------------------------------------------- |
360 | // raw bitmap access support | |
361 | // ---------------------------------------------------------------------------- | |
362 | ||
ffecfa5a JS |
363 | // ---------------------------------------------------------------------------- |
364 | // wxMask | |
365 | // ---------------------------------------------------------------------------- | |
366 | ||
367 | wxMask::wxMask() | |
368 | { | |
369 | m_maskBitmap = 0; | |
370 | } | |
371 | ||
372 | // Construct a mask from a bitmap and a colour indicating | |
373 | // the transparent area | |
374 | wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) | |
375 | { | |
376 | } | |
377 | ||
378 | // Construct a mask from a bitmap and a palette index indicating | |
379 | // the transparent area | |
380 | wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) | |
381 | { | |
382 | } | |
383 | ||
384 | // Construct a mask from a mono bitmap (copies the bitmap). | |
385 | wxMask::wxMask(const wxBitmap& bitmap) | |
386 | { | |
387 | } | |
388 | ||
389 | wxMask::~wxMask() | |
390 | { | |
391 | } | |
392 | ||
393 | // Create a mask from a mono bitmap (copies the bitmap). | |
394 | bool wxMask::Create(const wxBitmap& bitmap) | |
395 | { | |
4055ed82 | 396 | return false; |
ffecfa5a JS |
397 | } |
398 | ||
399 | // Create a mask from a bitmap and a palette index indicating | |
400 | // the transparent area | |
401 | bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) | |
402 | { | |
4055ed82 | 403 | return false; |
ffecfa5a JS |
404 | } |
405 | ||
406 | // Create a mask from a bitmap and a colour indicating | |
407 | // the transparent area | |
408 | bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) | |
409 | { | |
4055ed82 | 410 | return false; |
ffecfa5a JS |
411 | } |
412 | ||
413 | // ---------------------------------------------------------------------------- | |
414 | // wxBitmapHandler | |
415 | // ---------------------------------------------------------------------------- | |
416 | ||
417 | bool wxBitmapHandler::Create(wxGDIImage *image, | |
452418c4 | 418 | const void* data, |
ffecfa5a JS |
419 | long flags, |
420 | int width, int height, int depth) | |
421 | { | |
4055ed82 | 422 | return false; |
ffecfa5a JS |
423 | } |
424 | ||
425 | bool wxBitmapHandler::Load(wxGDIImage *image, | |
426 | const wxString& name, | |
427 | long flags, | |
428 | int width, int height) | |
429 | { | |
4055ed82 | 430 | return false; |
ffecfa5a JS |
431 | } |
432 | ||
433 | bool wxBitmapHandler::Save(wxGDIImage *image, | |
434 | const wxString& name, | |
435 | int type) | |
436 | { | |
4055ed82 | 437 | return false; |
ffecfa5a JS |
438 | } |
439 | ||
440 | bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), | |
452418c4 | 441 | const void* WXUNUSED(data), |
ffecfa5a JS |
442 | long WXUNUSED(type), |
443 | int WXUNUSED(width), | |
444 | int WXUNUSED(height), | |
445 | int WXUNUSED(depth)) | |
446 | { | |
4055ed82 | 447 | return false; |
ffecfa5a JS |
448 | } |
449 | ||
450 | bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), | |
451 | const wxString& WXUNUSED(name), | |
452 | long WXUNUSED(type), | |
453 | int WXUNUSED(desiredWidth), | |
454 | int WXUNUSED(desiredHeight)) | |
455 | { | |
4055ed82 | 456 | return false; |
ffecfa5a JS |
457 | } |
458 | ||
459 | bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), | |
460 | const wxString& WXUNUSED(name), | |
461 | int WXUNUSED(type), | |
462 | const wxPalette *WXUNUSED(palette)) | |
463 | { | |
4055ed82 | 464 | return false; |
ffecfa5a | 465 | } |