Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /***************************************************************************** |
2 | * Module for Microchip Graphics Library |
||
3 | * HIMAX HX8347 controller driver |
||
4 | ***************************************************************************** |
||
5 | * FileName: HX8347.c |
||
6 | * Dependencies: Graphics.h |
||
7 | * Processor: PIC24, PIC32 |
||
8 | * Compiler: MPLAB C30, MPLAB C32 |
||
9 | * Linker: MPLAB LINK30, MPLAB LINK32 |
||
10 | * Company: Microchip Technology Incorporated |
||
11 | * |
||
12 | * Software License Agreement |
||
13 | * |
||
14 | * Copyright © 2009 Microchip Technology Inc. All rights reserved. |
||
15 | * Microchip licenses to you the right to use, modify, copy and distribute |
||
16 | * Software only when embedded on a Microchip microcontroller or digital |
||
17 | * signal controller, which is integrated into your product or third party |
||
18 | * product (pursuant to the sublicense terms in the accompanying license |
||
19 | * agreement). |
||
20 | * |
||
21 | * You should refer to the license agreement accompanying this Software |
||
22 | * for additional information regarding your rights and obligations. |
||
23 | * |
||
24 | * SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY |
||
25 | * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
26 | * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR |
||
27 | * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR |
||
28 | * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, |
||
29 | * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT |
||
30 | * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, |
||
31 | * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, |
||
32 | * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY |
||
33 | * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), |
||
34 | * OR OTHER SIMILAR COSTS. |
||
35 | * |
||
36 | * Author Date Comment |
||
37 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
38 | * Anton Alkhimenok 05/26/09 |
||
39 | *****************************************************************************/ |
||
40 | #include "Graphics\Graphics.h" |
||
41 | |||
42 | // Color |
||
43 | WORD _color; |
||
44 | |||
45 | // Clipping region control |
||
46 | SHORT _clipRgn; |
||
47 | |||
48 | // Clipping region borders |
||
49 | SHORT _clipLeft; |
||
50 | SHORT _clipTop; |
||
51 | SHORT _clipRight; |
||
52 | SHORT _clipBottom; |
||
53 | |||
54 | /////////////////////// LOCAL FUNCTIONS PROTOTYPES //////////////////////////// |
||
55 | void SetReg(BYTE index, BYTE value); |
||
56 | void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch); |
||
57 | void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch); |
||
58 | void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch); |
||
59 | void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch); |
||
60 | |||
61 | void PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch); |
||
62 | void PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch); |
||
63 | void PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch); |
||
64 | void PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch); |
||
65 | |||
66 | |||
67 | |||
68 | /********************************************************************* |
||
69 | * Macros: WritePixel(data) |
||
70 | * |
||
71 | * Overview: Writes data |
||
72 | * |
||
73 | * PreCondition: none |
||
74 | * |
||
75 | * Input: data |
||
76 | * |
||
77 | * Output: none |
||
78 | * |
||
79 | * Side Effects: none |
||
80 | * |
||
81 | ********************************************************************/ |
||
82 | |||
83 | #ifdef USE_16BIT_PMP |
||
84 | #define WritePixel(data) DeviceWrite(data) |
||
85 | #else |
||
86 | #define WritePixel(data) \ |
||
87 | DeviceWrite( ((WORD_VAL) data).v[1] & 0xF8 ); \ |
||
88 | DeviceWrite( ((data >> 3) & 0xFC) ); \ |
||
89 | DeviceWrite( (((WORD_VAL) data).v[0] << 3) & 0xF8 ); |
||
90 | #endif |
||
91 | |||
92 | /********************************************************************* |
||
93 | * Function: void SetAddress(SHORT x, SHORT y) |
||
94 | * |
||
95 | * Overview: Writes address pointer. |
||
96 | * |
||
97 | * PreCondition: none |
||
98 | * |
||
99 | * Input: x - horizontal position |
||
100 | * y - vertical position |
||
101 | * |
||
102 | * Output: none |
||
103 | * |
||
104 | * Side Effects: none |
||
105 | * |
||
106 | ********************************************************************/ |
||
107 | inline void SetAddress(SHORT x, SHORT y) |
||
108 | { |
||
109 | DeviceSetCommand(); |
||
110 | DeviceWrite(0x02); |
||
111 | DeviceSetData(); |
||
112 | DeviceWrite(((WORD_VAL) (WORD) x).v[1]); |
||
113 | DeviceSetCommand(); |
||
114 | DeviceWrite(0x03); |
||
115 | DeviceSetData(); |
||
116 | DeviceWrite(((WORD_VAL) (WORD) x).v[0]); |
||
117 | DeviceSetCommand(); |
||
118 | DeviceWrite(0x06); |
||
119 | DeviceSetData(); |
||
120 | DeviceWrite(((WORD_VAL) (WORD) y).v[1]); |
||
121 | DeviceSetCommand(); |
||
122 | DeviceWrite(0x07); |
||
123 | DeviceSetData(); |
||
124 | DeviceWrite(((WORD_VAL) (WORD) y).v[0]); |
||
125 | DeviceSetCommand(); |
||
126 | DeviceWrite(0x22); |
||
127 | } |
||
128 | |||
129 | /********************************************************************* |
||
130 | * Function: void SetReg(BYTE index, BYTE value) |
||
131 | * |
||
132 | * PreCondition: none |
||
133 | * |
||
134 | * Input: index - register number |
||
135 | * value - value to be set |
||
136 | * |
||
137 | * Output: none |
||
138 | * |
||
139 | * Side Effects: none |
||
140 | * |
||
141 | * Overview: sets graphics controller register |
||
142 | * |
||
143 | * Note: none |
||
144 | * |
||
145 | ********************************************************************/ |
||
146 | void SetReg(BYTE index, BYTE value) |
||
147 | { |
||
148 | DeviceSelect(); |
||
149 | DeviceSetCommand(); |
||
150 | DeviceWrite(index); |
||
151 | DeviceSetData(); |
||
152 | DeviceWrite(value); |
||
153 | DeviceDeselect(); |
||
154 | } |
||
155 | |||
156 | /********************************************************************* |
||
157 | * Function: void ResetDevice() |
||
158 | * |
||
159 | * PreCondition: none |
||
160 | * |
||
161 | * Input: none |
||
162 | * |
||
163 | * Output: none |
||
164 | * |
||
165 | * Side Effects: none |
||
166 | * |
||
167 | * Overview: resets LCD, initializes PMP |
||
168 | * |
||
169 | * Note: none |
||
170 | * |
||
171 | ********************************************************************/ |
||
172 | void ResetDevice(void) |
||
173 | { |
||
174 | // Initialize the device |
||
175 | DeviceInit(); |
||
176 | |||
177 | #if (DISPLAY_CONTROLLER == HX8347A) |
||
178 | // Gamma for CMO 2.8 |
||
179 | SetReg(0x46, 0x95); // |
||
180 | SetReg(0x47, 0x51); // |
||
181 | SetReg(0x48, 0x00); // |
||
182 | SetReg(0x49, 0x36); // |
||
183 | SetReg(0x4A, 0x11); // |
||
184 | SetReg(0x4B, 0x66); // |
||
185 | SetReg(0x4C, 0x14); // |
||
186 | SetReg(0x4D, 0x77); // |
||
187 | SetReg(0x4E, 0x13); // |
||
188 | SetReg(0x4F, 0x4C); // |
||
189 | SetReg(0x50, 0x46); // |
||
190 | SetReg(0x51, 0x46); // |
||
191 | |||
192 | // Display |
||
193 | SetReg(0x90, 0x7F); // SAP=0111 1111 |
||
194 | SetReg(0x01, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 |
||
195 | #if (DISP_ORIENTATION == 0) |
||
196 | SetReg(0x16, 0xC8); // MY=1, MX=1, MV=0, BGR=1 |
||
197 | #else |
||
198 | SetReg(0x16, 0xA8); // MY=1, MX=0, MV=1, BGR=1 |
||
199 | #endif |
||
200 | SetReg(0x23, 0x95); // N_DC=1001 0101 |
||
201 | SetReg(0x24, 0x95); // P_DC=1001 0101 |
||
202 | SetReg(0x25, 0xFF); // I_DC=1111 1111 |
||
203 | SetReg(0x27, 0x06); // N_BP=0000 0110 |
||
204 | SetReg(0x28, 0x06); // N_FP=0000 0110 |
||
205 | SetReg(0x29, 0x06); // P_BP=0000 0110 |
||
206 | SetReg(0x2A, 0x06); // P_FP=0000 0110 |
||
207 | SetReg(0x2C, 0x06); // I_BP=0000 0110 |
||
208 | SetReg(0x2D, 0x06); // I_FP=0000 0110 |
||
209 | SetReg(0x3A, 0x01); // N_RTN=0000, N_NW=001 |
||
210 | SetReg(0x3B, 0x01); // P_RTN=0000, P_NW=001 |
||
211 | SetReg(0x3C, 0xF0); // I_RTN=1111, I_NW=000 |
||
212 | SetReg(0x3D, 0x00); // DIV=00 |
||
213 | DelayMs(20); |
||
214 | |||
215 | SetReg(0x10, 0xA6); // SS=0,GS=0 CSEL=110 |
||
216 | |||
217 | // Power Supply Setting |
||
218 | SetReg(0x19, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz |
||
219 | SetReg(0x93, 0x0C); // RADJ=1100, |
||
220 | DelayMs(10); |
||
221 | |||
222 | SetReg(0x20, 0x40); // BT=0100 |
||
223 | SetReg(0x1D, 0x07); // VC1=111 |
||
224 | SetReg(0x1E, 0x00); // VC3=000 |
||
225 | SetReg(0x1F, 0x04); // VRH=0100 4.12V |
||
226 | SetReg(0x44, 0x4D); // VCM=101 0000 3.21V |
||
227 | SetReg(0x45, 0x11); // VDV=1 0001 -1.19V |
||
228 | DelayMs(10); |
||
229 | |||
230 | SetReg(0x1C, 0x04); // AP=100 |
||
231 | DelayMs(20); |
||
232 | SetReg(0x43, 0x80); //set VCOMG=1 |
||
233 | DelayMs(5); |
||
234 | SetReg(0x1B, 0x18); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0 |
||
235 | DelayMs(40); |
||
236 | |||
237 | SetReg(0x1B, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 |
||
238 | DelayMs(40); |
||
239 | |||
240 | // Display ON Setting |
||
241 | SetReg(0x26, 0x04); // GON=0, DTE=0, D=01 |
||
242 | DelayMs(40); |
||
243 | SetReg(0x26, 0x24); // GON=1, DTE=0, D=01 |
||
244 | SetReg(0x26, 0x2C); // GON=1, DTE=0, D=11 |
||
245 | DelayMs(40); |
||
246 | |||
247 | SetReg(0x26, 0x3C); // GON=1, DTE=1, D=11 |
||
248 | SetReg(0x35, 0x38); // EQS=38h |
||
249 | SetReg(0x36, 0x78); // EQP=78h |
||
250 | SetReg(0x3E, 0x38); // SON=38h |
||
251 | SetReg(0x40, 0x0F); // GDON=0Fh |
||
252 | SetReg(0x41, 0xF0); // GDOFF |
||
253 | |||
254 | // Set spulse & rpulse |
||
255 | SetReg(0x57, 0x02); // Test mode='1' |
||
256 | SetReg(0x56, 0x84); // set Rpulse='1000',spulse='0100' |
||
257 | SetReg(0x57, 0x00); // Test mode= '0' |
||
258 | #if (DISP_ORIENTATION == 0) |
||
259 | SetReg(0x04, 0x00); |
||
260 | SetReg(0x05, 0xEF); |
||
261 | SetReg(0x08, 0x01); |
||
262 | SetReg(0x09, 0x3F); |
||
263 | #else |
||
264 | SetReg(0x04, 0x01); |
||
265 | SetReg(0x05, 0x3F); |
||
266 | SetReg(0x08, 0x00); |
||
267 | SetReg(0x09, 0xEF); |
||
268 | #endif |
||
269 | DelayMs(20); |
||
270 | |||
271 | #elif (DISPLAY_CONTROLLER == HX8347D) |
||
272 | |||
273 | // Driving ability setting |
||
274 | SetReg(0xEA,0x00); // PTBA[15:8] |
||
275 | SetReg(0xEB,0x20); // PTBA[7:0] |
||
276 | SetReg(0xEC,0x0C); // STBA[15:8] |
||
277 | SetReg(0xED,0xC4); // STBA[7:0] |
||
278 | SetReg(0xE8,0x40); // OPON[7:0] |
||
279 | SetReg(0xE9,0x38); // OPON1[7:0] |
||
280 | SetReg(0xF1,0x01); // OTPS1B |
||
281 | SetReg(0xF2,0x10); // GEN |
||
282 | SetReg(0x27,0xA3); // |
||
283 | |||
284 | // Gamma 2.8 setting |
||
285 | SetReg(0x40,0x00); // |
||
286 | SetReg(0x41,0x00); // |
||
287 | SetReg(0x42,0x01); // |
||
288 | SetReg(0x43,0x13); // |
||
289 | SetReg(0x44,0x10); // |
||
290 | SetReg(0x45,0x26); // |
||
291 | SetReg(0x46,0x08); // |
||
292 | SetReg(0x47,0x51); // |
||
293 | SetReg(0x48,0x02); // |
||
294 | SetReg(0x49,0x12); // |
||
295 | SetReg(0x4A,0x18); // |
||
296 | SetReg(0x4B,0x19); // |
||
297 | SetReg(0x4C,0x14); // |
||
298 | |||
299 | SetReg(0x50,0x19); // |
||
300 | SetReg(0x51,0x2F); // |
||
301 | SetReg(0x52,0x2C); // |
||
302 | SetReg(0x53,0x3E); // |
||
303 | SetReg(0x54,0x3F); // |
||
304 | SetReg(0x55,0x3F); // |
||
305 | SetReg(0x56,0x2E); // |
||
306 | SetReg(0x57,0x77); // |
||
307 | SetReg(0x58,0x0B); // |
||
308 | SetReg(0x59,0x06); // |
||
309 | SetReg(0x5A,0x07); // |
||
310 | SetReg(0x5B,0x0D); // |
||
311 | SetReg(0x5C,0x1D); // |
||
312 | SetReg(0x5D,0xCC); // |
||
313 | |||
314 | // Window setting |
||
315 | #if (DISP_ORIENTATION == 0) |
||
316 | SetReg(0x04,0x00); |
||
317 | SetReg(0x05,0xEF); |
||
318 | SetReg(0x08,0x01); |
||
319 | SetReg(0x09,0x3F); |
||
320 | #else |
||
321 | SetReg(0x04,0x01); |
||
322 | SetReg(0x05,0x3F); |
||
323 | SetReg(0x08,0x00); |
||
324 | SetReg(0x09,0xEF); |
||
325 | #endif |
||
326 | |||
327 | // Display Setting |
||
328 | //SetReg(0x01,0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 |
||
329 | |||
330 | #if (DISP_ORIENTATION == 0) |
||
331 | SetReg(0x16,0x08); // MY=0, MX=0, MV=0, BGR=1 |
||
332 | #else |
||
333 | SetReg(0x16,0x68); // MY=0, MX=1, MV=1, BGR=1 |
||
334 | #endif |
||
335 | |||
336 | |||
337 | // Power Voltage Setting |
||
338 | SetReg(0x1B,0x1B); // VRH = 4.65 |
||
339 | SetReg(0x1A,0x01); // BT |
||
340 | SetReg(0x24,0x2F); // VMH |
||
341 | SetReg(0x25,0x57); // VML |
||
342 | |||
343 | // Vcom offset |
||
344 | SetReg(0x23,0x8D); // FLICKER ADJUST |
||
345 | |||
346 | // Power ON Setting |
||
347 | SetReg(0x18,0x36); // |
||
348 | SetReg(0x19,0x01); // |
||
349 | SetReg(0x01,0x00); // |
||
350 | SetReg(0x1F,0x88); // |
||
351 | DelayMs(5); |
||
352 | SetReg(0x1F,0x80); // |
||
353 | DelayMs(5); |
||
354 | SetReg(0x1F,0x90); // |
||
355 | DelayMs(5); |
||
356 | SetReg(0x1F,0xD0); // |
||
357 | DelayMs(5); |
||
358 | |||
359 | // 65K Color Selection |
||
360 | SetReg(0x17,0x05); // |
||
361 | |||
362 | // Set Panel |
||
363 | SetReg(0x36,0x00); // |
||
364 | |||
365 | // Display ON Setting |
||
366 | SetReg(0x28,0x38); // |
||
367 | DelayMs( 40); |
||
368 | SetReg(0x28,0x3C); // |
||
369 | #endif |
||
370 | |||
371 | } |
||
372 | |||
373 | /********************************************************************* |
||
374 | * Function: void PutPixel(SHORT x, SHORT y) |
||
375 | * |
||
376 | * PreCondition: none |
||
377 | * |
||
378 | * Input: x,y - pixel coordinates |
||
379 | * |
||
380 | * Output: none |
||
381 | * |
||
382 | * Side Effects: none |
||
383 | * |
||
384 | * Overview: puts pixel |
||
385 | * |
||
386 | * Note: none |
||
387 | * |
||
388 | ********************************************************************/ |
||
389 | void PutPixel(SHORT x, SHORT y) |
||
390 | { |
||
391 | if(_clipRgn) |
||
392 | { |
||
393 | if(x < _clipLeft) |
||
394 | return; |
||
395 | if(x > _clipRight) |
||
396 | return; |
||
397 | if(y < _clipTop) |
||
398 | return; |
||
399 | if(y > _clipBottom) |
||
400 | return; |
||
401 | } |
||
402 | |||
403 | DeviceSelect; |
||
404 | SetAddress(x, y); |
||
405 | WritePixel(_color); |
||
406 | DeviceDeselect; |
||
407 | } |
||
408 | |||
409 | /********************************************************************* |
||
410 | * Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) |
||
411 | * |
||
412 | * PreCondition: none |
||
413 | * |
||
414 | * Input: left,top - top left corner coordinates, |
||
415 | * right,bottom - bottom right corner coordinates |
||
416 | * |
||
417 | * Output: none |
||
418 | * |
||
419 | * Side Effects: none |
||
420 | * |
||
421 | * Overview: draws rectangle filled with current color |
||
422 | * |
||
423 | * Note: none |
||
424 | * |
||
425 | ********************************************************************/ |
||
426 | WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) |
||
427 | { |
||
428 | register SHORT x, y; |
||
429 | |||
430 | #ifndef USE_NONBLOCKING_CONFIG |
||
431 | while(IsDeviceBusy() != 0); |
||
432 | |||
433 | /* Ready */ |
||
434 | #else |
||
435 | if(IsDeviceBusy() != 0) |
||
436 | return (0); |
||
437 | #endif |
||
438 | if(_clipRgn) |
||
439 | { |
||
440 | if(left < _clipLeft) |
||
441 | left = _clipLeft; |
||
442 | if(right > _clipRight) |
||
443 | right = _clipRight; |
||
444 | if(top < _clipTop) |
||
445 | top = _clipTop; |
||
446 | if(bottom > _clipBottom) |
||
447 | bottom = _clipBottom; |
||
448 | } |
||
449 | |||
450 | DeviceSelect; |
||
451 | for(y = top; y < bottom + 1; y++) |
||
452 | { |
||
453 | SetAddress(left, y); |
||
454 | for(x = left; x < right + 1; x++) |
||
455 | { |
||
456 | WritePixel(_color); |
||
457 | } |
||
458 | } |
||
459 | |||
460 | DeviceDeselect; |
||
461 | return (1); |
||
462 | } |
||
463 | |||
464 | /********************************************************************* |
||
465 | * Function: void ClearDevice(void) |
||
466 | * |
||
467 | * PreCondition: none |
||
468 | * |
||
469 | * Input: none |
||
470 | * |
||
471 | * Output: none |
||
472 | * |
||
473 | * Side Effects: none |
||
474 | * |
||
475 | * Overview: clears screen with current color |
||
476 | * |
||
477 | * Note: none |
||
478 | * |
||
479 | ********************************************************************/ |
||
480 | void ClearDevice(void) |
||
481 | { |
||
482 | DWORD counter; |
||
483 | |||
484 | DeviceSelect; |
||
485 | SetAddress(0, 0); |
||
486 | for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++) |
||
487 | { |
||
488 | WritePixel(_color); |
||
489 | } |
||
490 | |||
491 | DeviceDeselect; |
||
492 | } |
||
493 | |||
494 | /********************************************************************* |
||
495 | * Function: WORD PutImage(SHORT left, SHORT top, void* bitmap, BYTE stretch) |
||
496 | * |
||
497 | * PreCondition: none |
||
498 | * |
||
499 | * Input: left,top - left top image corner, |
||
500 | * bitmap - image pointer, |
||
501 | * stretch - image stretch factor |
||
502 | * |
||
503 | * Output: none |
||
504 | * |
||
505 | * Side Effects: none |
||
506 | * |
||
507 | * Overview: outputs image starting from left,top coordinates |
||
508 | * |
||
509 | * Note: image must be located in flash |
||
510 | * |
||
511 | ********************************************************************/ |
||
512 | #ifdef USE_DRV_PUTIMAGE |
||
513 | |||
514 | /* */ |
||
515 | WORD PutImage(SHORT left, SHORT top, void *bitmap, BYTE stretch) |
||
516 | { |
||
517 | FLASH_BYTE *flashAddress; |
||
518 | BYTE colorDepth; |
||
519 | WORD colorTemp; |
||
520 | |||
521 | #ifndef USE_NONBLOCKING_CONFIG |
||
522 | while(IsDeviceBusy() != 0); |
||
523 | |||
524 | /* Ready */ |
||
525 | #else |
||
526 | if(IsDeviceBusy() != 0) |
||
527 | return (0); |
||
528 | #endif |
||
529 | |||
530 | // Save current color |
||
531 | colorTemp = _color; |
||
532 | |||
533 | switch(*((SHORT *)bitmap)) |
||
534 | { |
||
535 | #ifdef USE_BITMAP_FLASH |
||
536 | |||
537 | case FLASH: |
||
538 | |||
539 | // Image address |
||
540 | flashAddress = ((BITMAP_FLASH *)bitmap)->address; |
||
541 | |||
542 | // Read color depth |
||
543 | colorDepth = *(flashAddress + 1); |
||
544 | |||
545 | // Draw picture |
||
546 | switch(colorDepth) |
||
547 | { |
||
548 | case 1: PutImage1BPP(left, top, flashAddress, stretch); break; |
||
549 | case 4: PutImage4BPP(left, top, flashAddress, stretch); break; |
||
550 | case 8: PutImage8BPP(left, top, flashAddress, stretch); break; |
||
551 | case 16: PutImage16BPP(left, top, flashAddress, stretch); break; |
||
552 | } |
||
553 | |||
554 | break; |
||
555 | #endif |
||
556 | #ifdef USE_BITMAP_EXTERNAL |
||
557 | |||
558 | case EXTERNAL: |
||
559 | |||
560 | // Get color depth |
||
561 | ExternalMemoryCallback(bitmap, 1, 1, &colorDepth); |
||
562 | |||
563 | // Draw picture |
||
564 | switch(colorDepth) |
||
565 | { |
||
566 | case 1: PutImage1BPPExt(left, top, bitmap, stretch); break; |
||
567 | case 4: PutImage4BPPExt(left, top, bitmap, stretch); break; |
||
568 | case 8: PutImage8BPPExt(left, top, bitmap, stretch); break; |
||
569 | case 16: PutImage16BPPExt(left, top, bitmap, stretch); break; |
||
570 | default: break; |
||
571 | } |
||
572 | |||
573 | break; |
||
574 | #endif |
||
575 | |||
576 | default: |
||
577 | break; |
||
578 | } |
||
579 | |||
580 | // Restore current color |
||
581 | _color = colorTemp; |
||
582 | return (1); |
||
583 | } |
||
584 | |||
585 | #ifdef USE_BITMAP_FLASH |
||
586 | |||
587 | /********************************************************************* |
||
588 | * Function: void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) |
||
589 | * |
||
590 | * PreCondition: none |
||
591 | * |
||
592 | * Input: left,top - left top image corner, |
||
593 | * bitmap - image pointer, |
||
594 | * stretch - image stretch factor |
||
595 | * |
||
596 | * Output: none |
||
597 | * |
||
598 | * Side Effects: none |
||
599 | * |
||
600 | * Overview: outputs monochrome image starting from left,top coordinates |
||
601 | * |
||
602 | * Note: image must be located in flash |
||
603 | * |
||
604 | ********************************************************************/ |
||
605 | void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch) |
||
606 | { |
||
607 | register FLASH_BYTE *flashAddress; |
||
608 | register FLASH_BYTE *tempFlashAddress; |
||
609 | BYTE temp; |
||
610 | WORD sizeX, sizeY; |
||
611 | WORD x, y; |
||
612 | BYTE stretchX, stretchY; |
||
613 | WORD pallete[2]; |
||
614 | BYTE mask; |
||
615 | |||
616 | // Move pointer to size information |
||
617 | flashAddress = bitmap + 2; |
||
618 | |||
619 | // Read image size |
||
620 | sizeY = *((FLASH_WORD *)flashAddress); |
||
621 | flashAddress += 2; |
||
622 | sizeX = *((FLASH_WORD *)flashAddress); |
||
623 | flashAddress += 2; |
||
624 | pallete[0] = *((FLASH_WORD *)flashAddress); |
||
625 | flashAddress += 2; |
||
626 | pallete[1] = *((FLASH_WORD *)flashAddress); |
||
627 | flashAddress += 2; |
||
628 | |||
629 | DeviceSelect; |
||
630 | for(y = 0; y < sizeY; y++) |
||
631 | { |
||
632 | tempFlashAddress = flashAddress; |
||
633 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
634 | { |
||
635 | flashAddress = tempFlashAddress; |
||
636 | SetAddress((WORD) left, (WORD) top); |
||
637 | mask = 0; |
||
638 | for(x = 0; x < sizeX; x++) |
||
639 | { |
||
640 | |||
641 | // Read 8 pixels from flash |
||
642 | if(mask == 0) |
||
643 | { |
||
644 | temp = *flashAddress; |
||
645 | flashAddress++; |
||
646 | mask = 0x80; |
||
647 | } |
||
648 | |||
649 | // Set color |
||
650 | if(mask & temp) |
||
651 | { |
||
652 | SetColor(pallete[1]); |
||
653 | } |
||
654 | else |
||
655 | { |
||
656 | SetColor(pallete[0]); |
||
657 | } |
||
658 | |||
659 | // Write pixel to screen |
||
660 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
661 | { |
||
662 | WritePixel(_color); |
||
663 | } |
||
664 | |||
665 | // Shift to the next pixel |
||
666 | mask >>= 1; |
||
667 | } |
||
668 | |||
669 | top++; |
||
670 | } |
||
671 | } |
||
672 | |||
673 | DeviceDeselect; |
||
674 | } |
||
675 | |||
676 | /********************************************************************* |
||
677 | * Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) |
||
678 | * |
||
679 | * PreCondition: none |
||
680 | * |
||
681 | * Input: left,top - left top image corner, bitmap - image pointer, |
||
682 | * stretch - image stretch factor |
||
683 | * |
||
684 | * Output: none |
||
685 | * |
||
686 | * Side Effects: none |
||
687 | * |
||
688 | * Overview: outputs 16 color image starting from left,top coordinates |
||
689 | * |
||
690 | * Note: image must be located in flash |
||
691 | * |
||
692 | ********************************************************************/ |
||
693 | void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch) |
||
694 | { |
||
695 | register FLASH_BYTE *flashAddress; |
||
696 | register FLASH_BYTE *tempFlashAddress; |
||
697 | WORD sizeX, sizeY; |
||
698 | register WORD x, y; |
||
699 | BYTE temp; |
||
700 | register BYTE stretchX, stretchY; |
||
701 | WORD pallete[16]; |
||
702 | WORD counter; |
||
703 | |||
704 | // Move pointer to size information |
||
705 | flashAddress = bitmap + 2; |
||
706 | |||
707 | // Read image size |
||
708 | sizeY = *((FLASH_WORD *)flashAddress); |
||
709 | flashAddress += 2; |
||
710 | sizeX = *((FLASH_WORD *)flashAddress); |
||
711 | flashAddress += 2; |
||
712 | |||
713 | // Read pallete |
||
714 | for(counter = 0; counter < 16; counter++) |
||
715 | { |
||
716 | pallete[counter] = *((FLASH_WORD *)flashAddress); |
||
717 | flashAddress += 2; |
||
718 | } |
||
719 | |||
720 | DeviceSelect; |
||
721 | for(y = 0; y < sizeY; y++) |
||
722 | { |
||
723 | tempFlashAddress = flashAddress; |
||
724 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
725 | { |
||
726 | flashAddress = tempFlashAddress; |
||
727 | SetAddress(left, top); |
||
728 | for(x = 0; x < sizeX; x++) |
||
729 | { |
||
730 | |||
731 | // Read 2 pixels from flash |
||
732 | if(x & 0x0001) |
||
733 | { |
||
734 | |||
735 | // second pixel in byte |
||
736 | SetColor(pallete[temp >> 4]); |
||
737 | } |
||
738 | else |
||
739 | { |
||
740 | temp = *flashAddress; |
||
741 | flashAddress++; |
||
742 | |||
743 | // first pixel in byte |
||
744 | SetColor(pallete[temp & 0x0f]); |
||
745 | } |
||
746 | |||
747 | // Write pixel to screen |
||
748 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
749 | { |
||
750 | WritePixel(_color); |
||
751 | } |
||
752 | } |
||
753 | |||
754 | top++; |
||
755 | } |
||
756 | } |
||
757 | |||
758 | DeviceDeselect; |
||
759 | } |
||
760 | |||
761 | /********************************************************************* |
||
762 | * Function: void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) |
||
763 | * |
||
764 | * PreCondition: none |
||
765 | * |
||
766 | * Input: left,top - left top image corner, bitmap - image pointer, |
||
767 | * stretch - image stretch factor |
||
768 | * |
||
769 | * Output: none |
||
770 | * |
||
771 | * Side Effects: none |
||
772 | * |
||
773 | * Overview: outputs 256 color image starting from left,top coordinates |
||
774 | * |
||
775 | * Note: image must be located in flash |
||
776 | * |
||
777 | ********************************************************************/ |
||
778 | void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch) |
||
779 | { |
||
780 | register FLASH_BYTE *flashAddress; |
||
781 | register FLASH_BYTE *tempFlashAddress; |
||
782 | WORD sizeX, sizeY; |
||
783 | WORD x, y; |
||
784 | BYTE temp; |
||
785 | BYTE stretchX, stretchY; |
||
786 | WORD pallete[256]; |
||
787 | WORD counter; |
||
788 | |||
789 | // Move pointer to size information |
||
790 | flashAddress = bitmap + 2; |
||
791 | |||
792 | // Read image size |
||
793 | sizeY = *((FLASH_WORD *)flashAddress); |
||
794 | flashAddress += 2; |
||
795 | sizeX = *((FLASH_WORD *)flashAddress); |
||
796 | flashAddress += 2; |
||
797 | |||
798 | // Read pallete |
||
799 | for(counter = 0; counter < 256; counter++) |
||
800 | { |
||
801 | pallete[counter] = *((FLASH_WORD *)flashAddress); |
||
802 | flashAddress += 2; |
||
803 | } |
||
804 | |||
805 | DeviceSelect; |
||
806 | for(y = 0; y < sizeY; y++) |
||
807 | { |
||
808 | tempFlashAddress = flashAddress; |
||
809 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
810 | { |
||
811 | flashAddress = tempFlashAddress; |
||
812 | SetAddress(left, top); |
||
813 | for(x = 0; x < sizeX; x++) |
||
814 | { |
||
815 | |||
816 | // Read pixels from flash |
||
817 | temp = *flashAddress; |
||
818 | flashAddress++; |
||
819 | |||
820 | // Set color |
||
821 | SetColor(pallete[temp]); |
||
822 | |||
823 | // Write pixel to screen |
||
824 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
825 | { |
||
826 | WritePixel(_color); |
||
827 | } |
||
828 | } |
||
829 | |||
830 | top++; |
||
831 | } |
||
832 | } |
||
833 | |||
834 | DeviceDeselect; |
||
835 | } |
||
836 | |||
837 | /********************************************************************* |
||
838 | * Function: void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) |
||
839 | * |
||
840 | * PreCondition: none |
||
841 | * |
||
842 | * Input: left,top - left top image corner, bitmap - image pointer, |
||
843 | * stretch - image stretch factor |
||
844 | * |
||
845 | * Output: none |
||
846 | * |
||
847 | * Side Effects: none |
||
848 | * |
||
849 | * Overview: outputs hicolor image starting from left,top coordinates |
||
850 | * |
||
851 | * Note: image must be located in flash |
||
852 | * |
||
853 | ********************************************************************/ |
||
854 | void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch) |
||
855 | { |
||
856 | register FLASH_WORD *flashAddress; |
||
857 | register FLASH_WORD *tempFlashAddress; |
||
858 | WORD sizeX, sizeY; |
||
859 | register WORD x, y; |
||
860 | WORD temp; |
||
861 | register BYTE stretchX, stretchY; |
||
862 | |||
863 | // Move pointer to size information |
||
864 | flashAddress = (FLASH_WORD *)bitmap + 1; |
||
865 | |||
866 | // Read image size |
||
867 | sizeY = *flashAddress; |
||
868 | flashAddress++; |
||
869 | sizeX = *flashAddress; |
||
870 | flashAddress++; |
||
871 | |||
872 | DeviceSelect; |
||
873 | for(y = 0; y < sizeY; y++) |
||
874 | { |
||
875 | tempFlashAddress = flashAddress; |
||
876 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
877 | { |
||
878 | flashAddress = tempFlashAddress; |
||
879 | SetAddress(left, top); |
||
880 | for(x = 0; x < sizeX; x++) |
||
881 | { |
||
882 | |||
883 | // Read pixels from flash |
||
884 | temp = *flashAddress; |
||
885 | flashAddress++; |
||
886 | |||
887 | // Set color |
||
888 | SetColor(temp); |
||
889 | |||
890 | // Write pixel to screen |
||
891 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
892 | { |
||
893 | WritePixel(_color); |
||
894 | } |
||
895 | } |
||
896 | |||
897 | top++; |
||
898 | } |
||
899 | } |
||
900 | |||
901 | DeviceDeselect; |
||
902 | } |
||
903 | |||
904 | #endif |
||
905 | #ifdef USE_BITMAP_EXTERNAL |
||
906 | |||
907 | /********************************************************************* |
||
908 | * Function: void PutImage1BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch) |
||
909 | * |
||
910 | * PreCondition: none |
||
911 | * |
||
912 | * Input: left,top - left top image corner, bitmap - image pointer, |
||
913 | * stretch - image stretch factor |
||
914 | * |
||
915 | * Output: none |
||
916 | * |
||
917 | * Side Effects: none |
||
918 | * |
||
919 | * Overview: outputs monochrome image starting from left,top coordinates |
||
920 | * |
||
921 | * Note: image must be located in external memory |
||
922 | * |
||
923 | ********************************************************************/ |
||
924 | void PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch) |
||
925 | { |
||
926 | register DWORD memOffset; |
||
927 | BITMAP_HEADER bmp; |
||
928 | WORD pallete[2]; |
||
929 | BYTE lineBuffer[((GetMaxX() + 1) / 8) + 1]; |
||
930 | BYTE *pData; |
||
931 | SHORT byteWidth; |
||
932 | |||
933 | BYTE temp; |
||
934 | BYTE mask; |
||
935 | WORD sizeX, sizeY; |
||
936 | WORD x, y; |
||
937 | BYTE stretchX, stretchY; |
||
938 | |||
939 | // Get bitmap header |
||
940 | ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp); |
||
941 | |||
942 | // Get pallete (2 entries) |
||
943 | ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 2 * sizeof(WORD), pallete); |
||
944 | |||
945 | // Set offset to the image data |
||
946 | memOffset = sizeof(BITMAP_HEADER) + 2 * sizeof(WORD); |
||
947 | |||
948 | // Line width in bytes |
||
949 | byteWidth = bmp.width >> 3; |
||
950 | if(bmp.width & 0x0007) |
||
951 | byteWidth++; |
||
952 | |||
953 | // Get size |
||
954 | sizeX = bmp.width; |
||
955 | sizeY = bmp.height; |
||
956 | |||
957 | for(y = 0; y < sizeY; y++) |
||
958 | { |
||
959 | |||
960 | // Get line |
||
961 | ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer); |
||
962 | memOffset += byteWidth; |
||
963 | DeviceSelect; |
||
964 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
965 | { |
||
966 | pData = lineBuffer; |
||
967 | SetAddress(left, top); |
||
968 | mask = 0; |
||
969 | for(x = 0; x < sizeX; x++) |
||
970 | { |
||
971 | |||
972 | // Read 8 pixels from flash |
||
973 | if(mask == 0) |
||
974 | { |
||
975 | temp = *pData++; |
||
976 | mask = 0x80; |
||
977 | } |
||
978 | |||
979 | // Set color |
||
980 | if(mask & temp) |
||
981 | { |
||
982 | SetColor(pallete[1]); |
||
983 | } |
||
984 | else |
||
985 | { |
||
986 | SetColor(pallete[0]); |
||
987 | } |
||
988 | |||
989 | // Write pixel to screen |
||
990 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
991 | { |
||
992 | WritePixel(_color); |
||
993 | } |
||
994 | |||
995 | // Shift to the next pixel |
||
996 | mask >>= 1; |
||
997 | } |
||
998 | |||
999 | top++; |
||
1000 | } |
||
1001 | |||
1002 | DeviceDeselect; |
||
1003 | } |
||
1004 | } |
||
1005 | |||
1006 | /********************************************************************* |
||
1007 | * Function: void PutImage4BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch) |
||
1008 | * |
||
1009 | * PreCondition: none |
||
1010 | * |
||
1011 | * Input: left,top - left top image corner, bitmap - image pointer, |
||
1012 | * stretch - image stretch factor |
||
1013 | * |
||
1014 | * Output: none |
||
1015 | * |
||
1016 | * Side Effects: none |
||
1017 | * |
||
1018 | * Overview: outputs monochrome image starting from left,top coordinates |
||
1019 | * |
||
1020 | * Note: image must be located in external memory |
||
1021 | * |
||
1022 | ********************************************************************/ |
||
1023 | void PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch) |
||
1024 | { |
||
1025 | register DWORD memOffset; |
||
1026 | BITMAP_HEADER bmp; |
||
1027 | WORD pallete[16]; |
||
1028 | BYTE lineBuffer[((GetMaxX() + 1) / 2) + 1]; |
||
1029 | BYTE *pData; |
||
1030 | SHORT byteWidth; |
||
1031 | |||
1032 | BYTE temp; |
||
1033 | WORD sizeX, sizeY; |
||
1034 | WORD x, y; |
||
1035 | BYTE stretchX, stretchY; |
||
1036 | |||
1037 | // Get bitmap header |
||
1038 | ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp); |
||
1039 | |||
1040 | // Get pallete (16 entries) |
||
1041 | ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 16 * sizeof(WORD), pallete); |
||
1042 | |||
1043 | // Set offset to the image data |
||
1044 | memOffset = sizeof(BITMAP_HEADER) + 16 * sizeof(WORD); |
||
1045 | |||
1046 | // Line width in bytes |
||
1047 | byteWidth = bmp.width >> 1; |
||
1048 | if(bmp.width & 0x0001) |
||
1049 | byteWidth++; |
||
1050 | |||
1051 | // Get size |
||
1052 | sizeX = bmp.width; |
||
1053 | sizeY = bmp.height; |
||
1054 | |||
1055 | for(y = 0; y < sizeY; y++) |
||
1056 | { |
||
1057 | |||
1058 | // Get line |
||
1059 | ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer); |
||
1060 | memOffset += byteWidth; |
||
1061 | DeviceSelect; |
||
1062 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
1063 | { |
||
1064 | pData = lineBuffer; |
||
1065 | SetAddress(left, top); |
||
1066 | |||
1067 | for(x = 0; x < sizeX; x++) |
||
1068 | { |
||
1069 | |||
1070 | // Read 2 pixels from flash |
||
1071 | if(x & 0x0001) |
||
1072 | { |
||
1073 | |||
1074 | // second pixel in byte |
||
1075 | SetColor(pallete[temp >> 4]); |
||
1076 | } |
||
1077 | else |
||
1078 | { |
||
1079 | temp = *pData++; |
||
1080 | |||
1081 | // first pixel in byte |
||
1082 | SetColor(pallete[temp & 0x0f]); |
||
1083 | } |
||
1084 | |||
1085 | // Write pixel to screen |
||
1086 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
1087 | { |
||
1088 | WritePixel(_color); |
||
1089 | } |
||
1090 | } |
||
1091 | |||
1092 | top++; |
||
1093 | } |
||
1094 | |||
1095 | DeviceDeselect; |
||
1096 | } |
||
1097 | } |
||
1098 | |||
1099 | /********************************************************************* |
||
1100 | * Function: void PutImage8BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch) |
||
1101 | * |
||
1102 | * PreCondition: none |
||
1103 | * |
||
1104 | * Input: left,top - left top image corner, bitmap - image pointer, |
||
1105 | * stretch - image stretch factor |
||
1106 | * |
||
1107 | * Output: none |
||
1108 | * |
||
1109 | * Side Effects: none |
||
1110 | * |
||
1111 | * Overview: outputs monochrome image starting from left,top coordinates |
||
1112 | * |
||
1113 | * Note: image must be located in external memory |
||
1114 | * |
||
1115 | ********************************************************************/ |
||
1116 | void PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch) |
||
1117 | { |
||
1118 | register DWORD memOffset; |
||
1119 | BITMAP_HEADER bmp; |
||
1120 | WORD pallete[256]; |
||
1121 | BYTE lineBuffer[(GetMaxX() + 1)]; |
||
1122 | BYTE *pData; |
||
1123 | |||
1124 | BYTE temp; |
||
1125 | WORD sizeX, sizeY; |
||
1126 | WORD x, y; |
||
1127 | BYTE stretchX, stretchY; |
||
1128 | |||
1129 | // Get bitmap header |
||
1130 | ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp); |
||
1131 | |||
1132 | // Get pallete (256 entries) |
||
1133 | ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 256 * sizeof(WORD), pallete); |
||
1134 | |||
1135 | // Set offset to the image data |
||
1136 | memOffset = sizeof(BITMAP_HEADER) + 256 * sizeof(WORD); |
||
1137 | |||
1138 | // Get size |
||
1139 | sizeX = bmp.width; |
||
1140 | sizeY = bmp.height; |
||
1141 | |||
1142 | for(y = 0; y < sizeY; y++) |
||
1143 | { |
||
1144 | |||
1145 | // Get line |
||
1146 | ExternalMemoryCallback(bitmap, memOffset, sizeX, lineBuffer); |
||
1147 | memOffset += sizeX; |
||
1148 | DeviceSelect; |
||
1149 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
1150 | { |
||
1151 | pData = lineBuffer; |
||
1152 | SetAddress(left, top); |
||
1153 | |||
1154 | for(x = 0; x < sizeX; x++) |
||
1155 | { |
||
1156 | temp = *pData++; |
||
1157 | SetColor(pallete[temp]); |
||
1158 | |||
1159 | // Write pixel to screen |
||
1160 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
1161 | { |
||
1162 | WritePixel(_color); |
||
1163 | } |
||
1164 | } |
||
1165 | |||
1166 | top++; |
||
1167 | } |
||
1168 | |||
1169 | DeviceDeselect; |
||
1170 | } |
||
1171 | } |
||
1172 | |||
1173 | /********************************************************************* |
||
1174 | * Function: void PutImage16BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch) |
||
1175 | * |
||
1176 | * PreCondition: none |
||
1177 | * |
||
1178 | * Input: left,top - left top image corner, bitmap - image pointer, |
||
1179 | * stretch - image stretch factor |
||
1180 | * |
||
1181 | * Output: none |
||
1182 | * |
||
1183 | * Side Effects: none |
||
1184 | * |
||
1185 | * Overview: outputs monochrome image starting from left,top coordinates |
||
1186 | * |
||
1187 | * Note: image must be located in external memory |
||
1188 | * |
||
1189 | ********************************************************************/ |
||
1190 | void PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch) |
||
1191 | { |
||
1192 | register DWORD memOffset; |
||
1193 | BITMAP_HEADER bmp; |
||
1194 | WORD lineBuffer[(GetMaxX() + 1)]; |
||
1195 | WORD *pData; |
||
1196 | WORD byteWidth; |
||
1197 | |||
1198 | WORD temp; |
||
1199 | WORD sizeX, sizeY; |
||
1200 | WORD x, y; |
||
1201 | BYTE stretchX, stretchY; |
||
1202 | |||
1203 | // Get bitmap header |
||
1204 | ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp); |
||
1205 | |||
1206 | // Set offset to the image data |
||
1207 | memOffset = sizeof(BITMAP_HEADER); |
||
1208 | |||
1209 | // Get size |
||
1210 | sizeX = bmp.width; |
||
1211 | sizeY = bmp.height; |
||
1212 | |||
1213 | byteWidth = sizeX << 1; |
||
1214 | |||
1215 | for(y = 0; y < sizeY; y++) |
||
1216 | { |
||
1217 | |||
1218 | // Get line |
||
1219 | ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer); |
||
1220 | memOffset += byteWidth; |
||
1221 | DeviceSelect; |
||
1222 | for(stretchY = 0; stretchY < stretch; stretchY++) |
||
1223 | { |
||
1224 | pData = lineBuffer; |
||
1225 | SetAddress(left, top); |
||
1226 | |||
1227 | for(x = 0; x < sizeX; x++) |
||
1228 | { |
||
1229 | temp = *pData++; |
||
1230 | SetColor(temp); |
||
1231 | |||
1232 | // Write pixel to screen |
||
1233 | for(stretchX = 0; stretchX < stretch; stretchX++) |
||
1234 | { |
||
1235 | WritePixel(_color); |
||
1236 | } |
||
1237 | } |
||
1238 | |||
1239 | top++; |
||
1240 | } |
||
1241 | |||
1242 | DeviceDeselect; |
||
1243 | } |
||
1244 | } |
||
1245 | |||
1246 | #endif |
||
1247 | #endif // USE_DRV_PUTIMAGE |
Powered by WebSVN v2.8.3