eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_imgdec_d4dint.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #include "d4d.h"
50 
51 
52 
53 
54 
55 static D4D_BOOL D4D_BmpHeaderCheckEndianism(const D4D_BMP* pBmp);
56 //static void D4D_LCD_DrawRBmp(D4D_COOR x, D4D_COOR y, const D4D_BMP* pBmp, D4D_BOOL greyScale, D4D_COOR radius);
57 
58 #if D4D_BMP_PAL_2_ENABLE != D4D_FALSE
59  D4D_COLOR D4D_GetPixel_BmpDecodeBmp2(D4D_D4DBMP_DECODE* pDecode);
60 #endif
61 
62 #if D4D_BMP_PAL_16_ENABLE != D4D_FALSE
63  D4D_COLOR D4D_GetPixel_BmpDecodeBmp16(D4D_D4DBMP_DECODE* pDecode);
64 #endif
65 
66 #if (D4D_BMP_256NOPAL_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_256_ENABLE != D4D_FALSE)
67  D4D_COLOR D4D_GetPixel_BmpDecodeBmp256(D4D_D4DBMP_DECODE* pDecode);
68 #endif
69 
70 #if (D4D_BMP_65536NOPAL_ENABLE != D4D_FALSE)
71  D4D_COLOR D4D_GetPixel_BmpDecodeBmp65K(D4D_D4DBMP_DECODE* pDecode);
72 #endif
73 
74 #if (D4D_BMP_256KNOPAL_ENABLE != D4D_FALSE)
75  D4D_COLOR D4D_GetPixel_BmpDecodeBmp256K(D4D_D4DBMP_DECODE* pDecode);
76 #endif
77 
78 #if (D4D_BMP_16MNOPAL_ENABLE != D4D_FALSE)
79  D4D_COLOR D4D_GetPixel_BmpDecodeBmp16M(D4D_D4DBMP_DECODE* pDecode);
80 #endif
81 
82 #if (D4D_BMP_16MNOPAL_ENABLE != D4D_FALSE) || (D4D_BMP_256KNOPAL_ENABLE != D4D_FALSE)
83  static LWord D4D_GetDataLong(D4D_D4DBMP_DECODE* pDecode, D4D_BOOL increment);
84 #endif
85 
86 #if (D4D_BMP_65536NOPAL_ENABLE != D4D_FALSE)
87  static Word D4D_GetDataWord(D4D_D4DBMP_DECODE* pDecode, D4D_BOOL increment);
88 #endif
89 
90 #if (D4D_BMP_256NOPAL_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_256_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_16_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_2_ENABLE != D4D_FALSE)
91  static Byte D4D_GetDataByte(D4D_D4DBMP_DECODE* pDecode, D4D_BOOL increment);
92 #endif
93 
94 
95 
96 /**************************************************************/
101 void D4D_ImgDecIntD4DDraw(D4D_COOR x, D4D_COOR y, D4D_CHAR* pFileName, D4D_BOOL greyScale, D4D_COOR radius)
102 {
103  // D4D_LCD_DrawRBmp(x, y, (D4D_BMP*)pFileName, greyScale, radius);
104 
105 
106  D4D_COOR width;
107  D4D_COOR height;
108  LWord cmode;
109 
110  D4D_COOR x2;
111  D4D_COOR y2;
112  LWord x_ix, y_ix;
113  void* pData;
114  D4D_BOOL endian;
115  D4D_D4DBMP_DECODE d4dbmp_decode;
116 
117  // check the version of bitmap header
118 
120  {
121  // bitmap header version 2
122  width = (D4D_COOR)D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->width;
123  height = (D4D_COOR)D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->height;
124  cmode = D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->colorMode;
125  pData = (void*)D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->pData;
126  }
127  else
128  {
129  Word* pHead = (Word*)((D4D_BMP*)pFileName)->pData;
130 
131  // bitmap header original version
132  #if D4D_ENDIAN == D4D_ENDIAN_BIG
133  D4D_UNUSED(endian);
134  width = (D4D_COOR)pHead[0];
135  height = (D4D_COOR)pHead[1];
136  cmode = pHead[2];
137  pData = pHead+3;
138  #else
139  endian = D4D_BmpHeaderCheckEndianism(((D4D_BMP*)pFileName));
140 
141  width = (D4D_COOR)(endian)? D4D_SwapWord(pHead[0]) : pHead[0];
142  height = (D4D_COOR)(endian)? D4D_SwapWord(pHead[1]) : pHead[1];
143  cmode = (endian)? D4D_SwapWord(pHead[2]) : pHead[2];
144  pData = pHead+3;
145  #endif
146  }
147 
148  x2 = (D4D_COOR)(x + width - 1);
149  y2 = (D4D_COOR)(y + height - 1);
150 
151  d4dbmp_decode.ix = 0;
152  d4dbmp_decode.rptCnt = 0;
153  d4dbmp_decode.curSubPxl = 0;
154  d4dbmp_decode.compress = (cmode & D4D_BMP_COMPRESS_MASK);
155  d4dbmp_decode.greyScale = greyScale;
156  d4dbmp_decode.pBmp = pData;
157  d4dbmp_decode.pPalette = (const Word*)((D4D_BMP*)pFileName)->pParam;
158 
159 
160  switch(cmode & (D4D_BMP_TYPE_MASK | D4D_BMP_CLR_DEPTH_MASK))
161  {
162 #if (D4D_BMP_16MNOPAL_ENABLE != D4D_FALSE)
163  case D4D_BMP_16MNOPAL:
164  d4dbmp_decode.GetPxlDecoder = D4D_GetPixel_BmpDecodeBmp16M;
165  d4dbmp_decode.GetDataFunc = (void*)D4D_GetDataLong;
166  break;
167 #endif
168 
169 
170 #if (D4D_BMP_256KNOPAL_ENABLE != D4D_FALSE)
171  case D4D_BMP_256KNOPAL:
172  d4dbmp_decode.GetPxlDecoder = D4D_GetPixel_BmpDecodeBmp256K;
173  d4dbmp_decode.GetDataFunc = (void*)D4D_GetDataLong;
174  break;
175 #endif
176 
177 #if (D4D_BMP_65536NOPAL_ENABLE != D4D_FALSE)
178  case D4D_BMP_65536NOPAL:
179  d4dbmp_decode.GetPxlDecoder = D4D_GetPixel_BmpDecodeBmp65K;
180  d4dbmp_decode.GetDataFunc = (void*)D4D_GetDataWord;
181  break;
182 #endif
183 
184 #if (D4D_BMP_256NOPAL_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_256_ENABLE != D4D_FALSE)
185  case D4D_BMP_256NOPAL:
186  case D4D_BMP_PAL_256:
187  d4dbmp_decode.GetPxlDecoder = D4D_GetPixel_BmpDecodeBmp256;
188  d4dbmp_decode.GetDataFunc = (void*)D4D_GetDataByte;
189  break;
190 #endif
191 
192 #if D4D_BMP_PAL_16_ENABLE != D4D_FALSE
193  case D4D_BMP_PAL_16:
194  d4dbmp_decode.GetPxlDecoder = D4D_GetPixel_BmpDecodeBmp16;
195  d4dbmp_decode.GetDataFunc = (void*)D4D_GetDataByte;
196  break;
197 #endif
198 
199 #if D4D_BMP_PAL_2_ENABLE != D4D_FALSE
200  case D4D_BMP_PAL_2:
201  d4dbmp_decode.GetPxlDecoder = D4D_GetPixel_BmpDecodeBmp2;
202  d4dbmp_decode.GetDataFunc = (void*)D4D_GetDataByte;
203  break;
204 #endif
205 
206  default:
207  // there are all non supported bitmaps
208  d4dbmp_decode.GetPxlDecoder = NULL;
209  d4dbmp_decode.GetDataFunc = NULL;
210  break;
211  }
212 
213 #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
214  if(radius)
215  {
216  LWord non_print_len;
217 
218  if(!d4dbmp_decode.GetPxlDecoder)
219  {
221  D4D_MoveToXY((D4D_COOR)(x + radius /2), (D4D_COOR)(y + radius /2));
222 
223  D4D_LineToXY((D4D_COOR)(x2 + radius /2), (D4D_COOR)(y2 + radius /2), D4D_LINE_THIN, D4D_ScreenGetScheme(D4D_GetActiveScreen())->fore);
224 
225  D4D_MoveToXY((D4D_COOR)(x + radius /2), (D4D_COOR)(y2 + radius /2));
226  D4D_LineToXY((D4D_COOR)(x2 + radius /2), (D4D_COOR)(y + radius /2), D4D_LINE_THIN, D4D_ScreenGetScheme(D4D_GetActiveScreen())->fore);
227  return;
228  }
229  // the main drawing function
230  for (y_ix = 0; y_ix < height; ++y_ix) // do for all lines
231  {
232  if(y_ix < radius)
233  non_print_len = D4D_RndCornerGetNonPrintedPxl(radius, (D4D_COOR)(y_ix)); // get len of non printed pixels
234  else if(((y2 - y) - y_ix) < radius)
235  non_print_len = D4D_RndCornerGetNonPrintedPxl(radius, (D4D_COOR)((y2 - y) - y_ix)); // get len of non printed pixels
236  else
237  non_print_len = 0;
238 
239  (void)D4D_LLD_LCD.D4DLCD_SetWindow ((D4D_COOR)(x + non_print_len), (D4D_COOR)(y + y_ix), (D4D_COOR)(x2 - non_print_len + 1), (D4D_COOR)(y + y_ix + 1));
240 
241  for (x_ix = 0; x_ix < width; ++x_ix) // do for all pixels on line
242  {
243 
244  if((x_ix >= non_print_len) && (x_ix <= ((x2 - x) - non_print_len)))
245  D4D_LLD_LCD.D4DLCD_Send_PixelColor(d4dbmp_decode.GetPxlDecoder(&d4dbmp_decode)); // and send color to display
246  else
247  d4dbmp_decode.GetPxlDecoder(&d4dbmp_decode); // just dummy read from file
248  }
249  }
250  }else
251 #else
252  D4D_UNUSED(radius);
253 #endif
254  {
255  if(!d4dbmp_decode.GetPxlDecoder)
256  {
259 
260  D4D_MoveToXY(x, y2);
262  return;
263  }
264  // Define window
265  (void)D4D_LLD_LCD.D4DLCD_SetWindow (x, y, x2, y2);
266 
267  x_ix = (LWord) (width * height); // Count the overall pixel count
268 
269  // the main drawing function
270  for (y_ix=0; y_ix<x_ix; ++y_ix) // do for all pixels
271  D4D_LLD_LCD.D4DLCD_Send_PixelColor(d4dbmp_decode.GetPxlDecoder(&d4dbmp_decode)); // write same pixels to display
272  }
273 #if D4D_LLD_FLUSH_ELEMENT != D4D_FALSE
275 #endif
276 }
277 
278 
279 /**************************************************************/
285 {
286  D4D_BMP* pBmp = (D4D_BMP*)pFileName;
287  Word* pHead;
288 
289  if(pBmp == NULL)
290  return 0;
291 
292  // bitmap header version 2
294  return (D4D_COOR)D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->width;
295 
296  pHead = (Word*)pBmp->pData;
297 
299  return (D4D_COOR) pHead[0];
300  #else
301  return (D4D_COOR) (D4D_BmpHeaderCheckEndianism(pBmp))? D4D_SwapWord(pHead[0]) : pHead[0];
302  #endif
303 }
304 
305 /**************************************************************/
311 {
312  Word* pHead;
313  D4D_BMP* pBmp = (D4D_BMP*)pFileName;
314 
315  if(pBmp == NULL)
316  return 0;
317 
318  // bitmap header version 2
320  return (D4D_COOR)D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->height;
321 
322 
323  pHead = (Word*)pBmp->pData;
324 
326  return (D4D_COOR) pHead[1];
327  #else
328  return (D4D_COOR) (D4D_BmpHeaderCheckEndianism(pBmp))? D4D_SwapWord(pHead[1]) : pHead[1];
329  #endif
330 }
331 
332 
333 /**************************************************************/
339 {
340  Word* pHead;
341  D4D_BMP* pBmp = (D4D_BMP*)pFileName;
342  D4D_SIZE tmpSize = { 0, 0};
343 
344  // bitmap header version 2
346  {
347  tmpSize.cx = (D4D_COOR)D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->width;
348  tmpSize.cy = (D4D_COOR)D4D_GET_IMG_HEADER_2_FROM_FILENAME(pFileName)->height;
349  }
350  else
351  {
352  #if D4D_ENDIAN == D4D_ENDIAN_BIG
353  if(pBmp != NULL)
354  {
355  pHead = (Word*)pBmp->pData;
356  tmpSize.cx = (D4D_COOR) (pHead[0]);
357  tmpSize.cy = (D4D_COOR) (pHead[1]);
358  }
359  #else
360  if(pBmp != NULL)
361  {
362  D4D_BOOL endian = D4D_BmpHeaderCheckEndianism(pBmp);
363  pHead = (Word*)pBmp->pData;
364  tmpSize.cx = (D4D_COOR)(endian)? D4D_SwapWord(pHead[0]) : pHead[0];
365  tmpSize.cy = (D4D_COOR)(endian)? D4D_SwapWord(pHead[1]) : pHead[1];
366  }
367  #endif
368  }
369  return tmpSize;
370 }
371 
372 /**************************************************************/
377 int D4D_ImgDecIntD4DGetHeader(D4D_CHAR* pFileName, void* pBuff, int max_size)
378 {
379  Word* pHead;
380  D4D_BMP* pBmp = (D4D_BMP*)pFileName;
381  int size;
382 
383 
384 
385  if(pBmp != NULL)
386  return 0;
387  // bitmap header version 2
389  {
390  if(max_size < D4D_IMG_HEADER_2_D4DINT_SIZE)
391  return 0;
394  }
395  else
396  {
397  if(max_size < D4D_IMG_HEADER_D4DINT_SIZE)
398  return 0;
399 
401 
402  #if D4D_ENDIAN == D4D_ENDIAN_BIG
403  pHead = (Word*)pBmp->pData;
404  ((D4D_IMG_HEADER_D4DINT*)pBuff)->width = (D4D_COOR) pHead[0];
405  ((D4D_IMG_HEADER_D4DINT*)pBuff)->height = (D4D_COOR) pHead[1];
406  ((D4D_IMG_HEADER_D4DINT*)pBuff)->colorMode = (Word) pHead[2];
407  #else
408  {
409  D4D_BOOL endian = D4D_BmpHeaderCheckEndianism(pBmp);
410  pHead = (Word*)pBmp->pData;
411  ((D4D_IMG_HEADER_D4DINT*)pBuff)->width = (D4D_COOR)(endian)? D4D_SwapWord(pHead[0]) : pHead[0];
412  ((D4D_IMG_HEADER_D4DINT*)pBuff)->height = (D4D_COOR)(endian)? D4D_SwapWord(pHead[1]) : pHead[1];
413  ((D4D_IMG_HEADER_D4DINT*)pBuff)->colorMode = (D4D_COOR)(endian)? D4D_SwapWord(pHead[2]) : pHead[2];
414  }
415  #endif
416  }
417  return size;
418 }
419 
420 
421 /**************************************************************/
426 #if (D4D_BMP_16MNOPAL_ENABLE != D4D_FALSE)
427 D4D_COLOR D4D_GetPixel_BmpDecodeBmp16M(D4D_D4DBMP_DECODE* pDecode)
428 {
429  // setup the startup condition (the previos color must be different than current one)
430  if(!pDecode->ix)
431  pDecode->pxlClrPrv = ~GET_DATA_LONG(pDecode, D4D_FALSE);
432 
433 
434  if(pDecode->rptCnt == 0)
435  {
436  pDecode->pxlClr = GET_DATA_LONG(pDecode, D4D_TRUE); // load the color of pixel
437 
438  pDecode->pxlClrRet = D4D_COLOR_FROM_888((LWord)(pDecode->pxlClr));
439 
440  if(pDecode->greyScale)
441  pDecode->pxlClrRet = D4D_GetGreyScale(pDecode->pxlClrRet); // if needed convert it to grayscale
442  }
443 
444  if(pDecode->compress) // case that bitmap is compressed
445  {
446  if (pDecode->pxlClrPrv == pDecode->pxlClr) // check the two same colors in row
447  {
448  if(pDecode->rptCnt == 0)
449  {
450 
451  pDecode->rptCnt = GET_DATA_LONG(pDecode, D4D_TRUE); // load the count of repeated pixels
452  if(pDecode->rptCnt)
453  return pDecode->pxlClrRet;
454  }
455 
456  if(pDecode->rptCnt)
457  pDecode->rptCnt--;
458 
459  if(!pDecode->rptCnt)
460  pDecode->pxlClr = ~GET_DATA_LONG(pDecode, D4D_FALSE); // devalue the last information of drawed pixel
461  }
462  pDecode->pxlClrPrv = pDecode->pxlClr; // store the last drawed pixel
463  }
464 
465  return pDecode->pxlClrRet;
466 }
467 #endif
468 
469 /**************************************************************/
474 #if (D4D_BMP_256KNOPAL_ENABLE != D4D_FALSE)
475 D4D_COLOR D4D_GetPixel_BmpDecodeBmp256K(D4D_D4DBMP_DECODE* pDecode)
476 {
477  // setup the startup condition (the previos color must be different than current one)
478  if(!pDecode->ix)
479  pDecode->pxlClrPrv = ~GET_DATA_LONG(pDecode, D4D_FALSE);;
480 
481 
482  if(pDecode->rptCnt == 0)
483  {
484  pDecode->pxlClr = GET_DATA_LONG(pDecode, D4D_TRUE);; // load the color of pixel
485 
486  pDecode->pxlClrRet = D4D_COLOR_FROM_666((LWord)(pDecode->pxlClr));
487 
488  if(pDecode->greyScale)
489  pDecode->pxlClrRet = D4D_GetGreyScale(pDecode->pxlClrRet); // if needed convert it to grayscale
490  }
491 
492  if(pDecode->compress) // case that bitmap is compressed
493  {
494  if (pDecode->pxlClrPrv == pDecode->pxlClr) // check the two same colors in row
495  {
496  if(pDecode->rptCnt == 0)
497  {
498 
499  pDecode->rptCnt = GET_DATA_LONG(pDecode, D4D_TRUE);; // load the count of repeated pixels
500  if(pDecode->rptCnt)
501  return pDecode->pxlClrRet;
502  }
503 
504  if(pDecode->rptCnt)
505  pDecode->rptCnt--;
506 
507  if(!pDecode->rptCnt)
508  pDecode->pxlClr = ~GET_DATA_LONG(pDecode, D4D_FALSE); // devalue the last information of drawed pixel
509  }
510  pDecode->pxlClrPrv = pDecode->pxlClr; // store the last drawed pixel
511  }
512 
513  return pDecode->pxlClrRet;
514 }
515 #endif
516 
517 /**************************************************************/
522 #if (D4D_BMP_65536NOPAL_ENABLE != D4D_FALSE)
523 D4D_COLOR D4D_GetPixel_BmpDecodeBmp65K(D4D_D4DBMP_DECODE* pDecode)
524 {
525  // setup the startup condition (the previos color must be different than current one)
526  if(!pDecode->ix)
527  pDecode->pxlClrPrv = ~GET_DATA_WORD(pDecode, D4D_FALSE);
528 
529 
530  if(pDecode->rptCnt == 0)
531  {
532  pDecode->pxlClr = GET_DATA_WORD(pDecode, D4D_TRUE); // load the color of pixel
533 
534  pDecode->pxlClrRet = D4D_COLOR_FROM_565((Word)(pDecode->pxlClr));
535 
536  if(pDecode->greyScale)
537  pDecode->pxlClrRet = D4D_GetGreyScale(pDecode->pxlClrRet); // if needed convert it to grayscale
538  }
539 
540  if(pDecode->compress) // case that bitmap is compressed
541  {
542  if (pDecode->pxlClrPrv == pDecode->pxlClr) // check the two same colors in row
543  {
544  if(pDecode->rptCnt == 0)
545  {
546 
547  pDecode->rptCnt = GET_DATA_WORD(pDecode, D4D_TRUE); // load the count of repeated pixels
548  if(pDecode->rptCnt)
549  return pDecode->pxlClrRet;
550  }
551 
552  if(pDecode->rptCnt)
553  pDecode->rptCnt--;
554 
555  if(!pDecode->rptCnt)
556  pDecode->pxlClr = ~GET_DATA_WORD(pDecode, D4D_FALSE); // devalue the last information of drawed pixel
557  }
558  pDecode->pxlClrPrv = pDecode->pxlClr; // store the last drawed pixel
559  }
560 
561 
562  return pDecode->pxlClrRet;
563 
564 }
565 #endif
566 
567 /**************************************************************/
572 #if (D4D_BMP_256NOPAL_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_256_ENABLE != D4D_FALSE)
573 D4D_COLOR D4D_GetPixel_BmpDecodeBmp256(D4D_D4DBMP_DECODE* pDecode)
574 {
575  // setup the startup condition (the previos color must be different than current one)
576  if(!pDecode->ix)
577  pDecode->pxlClrPrv = ~GET_DATA_BYTE(pDecode, D4D_FALSE);
578 
579 
580  if(pDecode->rptCnt == 0)
581  {
582  pDecode->pxlClr = GET_DATA_BYTE(pDecode, D4D_TRUE); // load the color of pixel
583 
584  if(pDecode->pPalette)
585  pDecode->pxlClrRet = D4D_COLOR_FROM_565(((Word*)(pDecode->pPalette))[pDecode->pxlClr]);
586  else
587  pDecode->pxlClrRet = D4D_COLOR_FROM_332((Byte)pDecode->pxlClr); // convert it from 332 to d4d color system
588 
589 
590 
591  if(pDecode->greyScale)
592  pDecode->pxlClrRet = D4D_GetGreyScale(pDecode->pxlClrRet); // if needed convert it to grayscale
593  }
594 
595  if(pDecode->compress) // case that bitmap is compressed
596  {
597  if (pDecode->pxlClrPrv == pDecode->pxlClr) // check the two same colors in row
598  {
599  if(pDecode->rptCnt == 0)
600  {
601 
602  pDecode->rptCnt = GET_DATA_BYTE(pDecode, D4D_TRUE); // load the count of repeated pixels
603  if(pDecode->rptCnt)
604  return pDecode->pxlClrRet;
605  }
606 
607  if(pDecode->rptCnt)
608  pDecode->rptCnt--;
609 
610  if(!pDecode->rptCnt)
611  pDecode->pxlClr = ~GET_DATA_BYTE(pDecode, D4D_FALSE); // devalue the last information of drawed pixel
612  }
613  pDecode->pxlClrPrv = pDecode->pxlClr; // store the last drawed pixel
614  }
615 
616 
617  return pDecode->pxlClrRet;
618 
619 }
620 #endif
621 
622 /**************************************************************/
627 #if (D4D_BMP_PAL_16_ENABLE != D4D_FALSE)
628 
629 static D4D_COLOR D4D_GetPxl16(D4D_D4DBMP_DECODE* pDecode)
630 {
631  Byte ix = pDecode->pxlCode; // this solution with pointers solve endianism issue
632 
633  if(pDecode->curSubPxl++)
634  ix &= 0x0f;
635  else
636  ix = (Byte)((ix >> 4) & 0x0f);
637 
638  if(pDecode->pPalette)
639  pDecode->pxlClrRet = D4D_COLOR_FROM_565(((Word*)(pDecode->pPalette))[ix]);
640  else
641  pDecode->pxlClrRet = D4D_COLOR_BLACK; // at the moment there isn't support 16 color bitmaps without pallete
642 
643  if(pDecode->greyScale)
644  pDecode->pxlClrRet = D4D_GetGreyScale(pDecode->pxlClrRet); // if needed convert it to grayscale
645 
646 
647 
648  return pDecode->pxlClrRet;
649 }
650 
651 
652 D4D_COLOR D4D_GetPixel_BmpDecodeBmp16(D4D_D4DBMP_DECODE* pDecode)
653 {
654  // setup the startup condition (the previos color must be different than current one)
655  if(!pDecode->ix)
656  pDecode->pxlClrPrv = ~GET_DATA_BYTE(pDecode, D4D_FALSE);
657 
658  pDecode->curSubPxl &= 0x01;
659 
660  if(pDecode->curSubPxl == 0)
661  {
662  if(pDecode->rptCnt == 0)
663  {
664  pDecode->pxlClr = GET_DATA_BYTE(pDecode, D4D_TRUE); // load the color of pixel
665  pDecode->pxlCode = (Byte)pDecode->pxlClr; // to do Kinetis
666  }
667 
668  if(pDecode->compress) // case that bitmap is compressed
669  {
670  if (pDecode->pxlClrPrv == pDecode->pxlClr) // check the two same colors in row
671  {
672  if(pDecode->rptCnt == 0)
673  {
674 
675  pDecode->rptCnt = GET_DATA_BYTE(pDecode, D4D_TRUE); // load the count of repeated pixels
676  if(pDecode->rptCnt)
677  return D4D_GetPxl16(pDecode); // to do
678  }
679 
680  if(pDecode->rptCnt)
681  pDecode->rptCnt--;
682 
683  if(!pDecode->rptCnt)
684  pDecode->pxlClr = ~GET_DATA_BYTE(pDecode, D4D_FALSE); // devalue the last information of drawed pixel
685  }
686  pDecode->pxlClrPrv = pDecode->pxlClr; // store the last drawed pixel
687  }
688  }
689 
690 
691  return D4D_GetPxl16(pDecode);
692 }
693 
694 #endif
695 
696 
697 /**************************************************************/
703 #if (D4D_BMP_PAL_2_ENABLE != D4D_FALSE)
704 
705 static D4D_COLOR D4D_GetPxl2(D4D_D4DBMP_DECODE* pDecode)
706 {
707  Byte ix = pDecode->pxlCode; // this solution with pointers solve endianism issue
708 
709  ix = (Byte)((ix >> (7 - (pDecode->curSubPxl))) & 0x01);
710 
711  pDecode->curSubPxl++;
712 
713  if(pDecode->pPalette)
714  pDecode->pxlClrRet = D4D_COLOR_FROM_565(((Word*)(pDecode->pPalette))[ix]);
715  else
716  pDecode->pxlClrRet = D4D_COLOR_BLACK; // at the moment there isn't support monocolor bitmaps without pallete
717 
718  if(pDecode->greyScale)
719  pDecode->pxlClrRet = D4D_GetGreyScale(pDecode->pxlClrRet); // if needed convert it to grayscale
720 
721 
722 
723  return pDecode->pxlClrRet;
724 }
725 
726 D4D_COLOR D4D_GetPixel_BmpDecodeBmp2(D4D_D4DBMP_DECODE* pDecode)
727 {
728  // setup the startup condition (the previos color must be different than current one)
729  if(!pDecode->ix)
730  pDecode->pxlClrPrv = ~GET_DATA_BYTE(pDecode, D4D_FALSE);
731 
732  pDecode->curSubPxl &= 0x07;
733 
734  if(pDecode->curSubPxl == 0)
735  {
736  if(pDecode->rptCnt == 0)
737  {
738  pDecode->pxlClr = GET_DATA_BYTE(pDecode, D4D_TRUE); // load the color of pixel
739  pDecode->pxlCode = (Byte)pDecode->pxlClr; // to do Kinetis
740  //Byte ix = (*(Byte*)(&pDecode->pxlClr)); // this solution with pointers solve endianism issue
741 
742  }
743 
744  if(pDecode->compress) // case that bitmap is compressed
745  {
746  if (pDecode->pxlClrPrv == pDecode->pxlClr) // check the two same colors in row
747  {
748  if(pDecode->rptCnt == 0)
749  {
750 
751  pDecode->rptCnt = GET_DATA_BYTE(pDecode, D4D_TRUE); // load the count of repeated pixels
752  if(pDecode->rptCnt)
753  return D4D_GetPxl2(pDecode);
754  }
755 
756  if(pDecode->rptCnt)
757  pDecode->rptCnt--;
758 
759  if(!pDecode->rptCnt)
760  pDecode->pxlClr = ~GET_DATA_BYTE(pDecode, D4D_FALSE); // devalue the last information of drawed pixel
761  }
762  pDecode->pxlClrPrv = pDecode->pxlClr; // store the last drawed pixel
763  }
764  }
765 
766 
767  return D4D_GetPxl2(pDecode);
768 }
769 
770 #endif
771 
772 
774 {
775  Word* pHead = (Word*)pBmp->pData;
776 
777  if(pHead[2] & D4D_BMP_ENDIAN_FLAG)
778  return D4D_FALSE;
779  else
780  return D4D_TRUE;
781 }
782 
783 /**************************************************************/
788 #if (D4D_BMP_16MNOPAL_ENABLE != D4D_FALSE) || (D4D_BMP_256KNOPAL_ENABLE != D4D_FALSE)
789 static LWord D4D_GetDataLong(D4D_D4DBMP_DECODE* pDecode, D4D_BOOL increment)
790 {
791  LWord ret = ((LWord*)pDecode->pBmp)[pDecode->ix];
792 
793  if(increment)
794  pDecode->ix++;
795 
796  return ret;
797 }
798 #endif
799 
800 #if (D4D_BMP_65536NOPAL_ENABLE != D4D_FALSE)
801 static Word D4D_GetDataWord(D4D_D4DBMP_DECODE* pDecode, D4D_BOOL increment)
802 {
803  Word ret = ((Word*)pDecode->pBmp)[pDecode->ix];
804 
805  if(increment)
806  pDecode->ix++;
807 
808  return ret;
809 }
810 #endif
811 
812 #if (D4D_BMP_256NOPAL_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_256_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_16_ENABLE != D4D_FALSE) || (D4D_BMP_PAL_2_ENABLE != D4D_FALSE)
813 static Byte D4D_GetDataByte(D4D_D4DBMP_DECODE* pDecode, D4D_BOOL increment)
814 {
815  Byte ret = ((Byte*)pDecode->pBmp)[pDecode->ix];
816 
817  if(increment)
818  pDecode->ix++;
819 
820  return ret;
821 }
822 #endif
#define D4D_COLOR_BLACK
Black color (0, 0, 0)
Definition: d4d_scheme.h:119
D4D_COOR D4D_ImgDecIntD4DGetHeight(D4D_CHAR *pFileName)
D4D driver external pictures d4d decoder functions header file.
void D4D_RBoxXY(D4D_COOR x1, D4D_COOR y1, D4D_COOR x2, D4D_COOR y2, D4D_LINETYPE ltype, D4D_COLOR colorLine, D4D_COLOR colorFill, D4D_COOR radius)
Function draw filled rectangle with outline on the screen with round corners.
#define D4D_GET_IMG_HEADER_2_FROM_FILENAME(file)
void(* D4DLCD_FlushBuffer)(D4DLCD_FLUSH_MODE mode)
The LCD driver flush function.
Definition: d4d_lldapi.h:154
void D4D_ImgDecIntD4DDraw(D4D_COOR x, D4D_COOR y, D4D_CHAR *pFileName, D4D_BOOL greyScale, D4D_COOR radius)
#define D4D_FALSE
This is definition of boolean operation value in eGUI - FALSE.
Definition: d4d_types.h:104
#define D4D_BMP_PAL_16
Word D4D_SwapWord(Word n)
The function swap bytes in Word.
Definition: d4d_extsrc.c:352
The flush after one basic element is draw.
Definition: d4d_lldapi.h:138
#define GET_DATA_BYTE(pBmp_dec, inc)
void D4D_MoveToXY(D4D_COOR x, D4D_COOR y)
Function move logic cursor to new position.
#define D4D_TRUE
This is definition of boolean operation value in eGUI - TRUE.
Definition: d4d_types.h:106
#define D4D_BMP_ENDIAN_FLAG
D4D_COOR D4D_ImgDecIntD4DGetWidth(D4D_CHAR *pFileName)
#define D4D_COLOR_FROM_666(color666)
Definition: d4d_scheme.h:441
D4D Driver main header file.
#define D4D_BMP_CLR_DEPTH_MASK
D4D Driver private header file.
D4D_COOR cx
Size in axis X (width)
Definition: d4d_types.h:232
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
#define D4D_IMG_HEADER_2_D4DINT_SIZE
Macro that define the size of version 2 header of bitmap.
#define D4D_BMP_256NOPAL
#define D4D_BMP_TYPE_MASK
#define D4D_IMG_HEADER_D4DINT_SIZE
Macro that define the size of original header of bitmap.
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
#define D4D_BMP_16MNOPAL
D4D_CLR_SCHEME * D4D_ScreenGetScheme(D4D_SCREEN *pScreen)
#define D4D_BMP_PAL_256
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
D4D_SIZE D4D_ImgDecIntD4DGetSize(D4D_CHAR *pFileName)
#define D4D_COLOR_FROM_332(color332)
Definition: d4d_scheme.h:444
void D4D_BoxXY(D4D_COOR x1, D4D_COOR y1, D4D_COOR x2, D4D_COOR y2, D4D_LINETYPE ltype, D4D_COLOR colorLine, D4D_COLOR colorFill)
Function draw filled rectangle with outline on the screen.
unsigned long LWord
Type definition of LWord (unsigned 32-bit).
Definition: d4d_types.h:167
#define GET_DATA_WORD(pBmp_dec, inc)
D4D_SCREEN * D4D_GetActiveScreen(void)
Returns pointer to current active screen.
Definition: d4d_screen.c:78
D4D_BMP eGUI main image structure.
Definition: d4d_bmp.h:100
D4D_COOR D4D_RndCornerGetNonPrintedPxl(D4D_COOR radius, D4D_COOR line)
Function that counts number of printed pixels in specified line of circle quadrant.
#define D4D_BMP_65536NOPAL
int D4D_ImgDecIntD4DGetHeader(D4D_CHAR *pFileName, void *pBuff, int max_size)
D4D_COOR cy
Size in axis Y (height)
Definition: d4d_types.h:233
const void * pData
Pointer to data to internal memory. In case of external source of image this must be NULL...
Definition: d4d_bmp.h:102
#define D4D_ENDIAN
This macro is used to specify current Endianim of CPU architecture. If not defined, the macro is defined by used CPU type as a default.
Definition: d4d_base.h:191
const D4DLCD_FUNCTIONS D4D_LLD_LCD
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
#define D4D_UNUSED(x)
Macro used just for notify compiler that the input parameter is not used.
Definition: d4d_base.h:504
static D4D_BOOL D4D_BmpHeaderCheckEndianism(const D4D_BMP *pBmp)
char D4D_CHAR
Type definition of eGUI ASCII character.
Definition: d4d_types.h:280
#define D4D_IMG_HEADER_2_KEY_D4DINT
Type definition of eGUI size structure.
Definition: d4d_types.h:230
#define D4D_BMP_PAL_2
#define D4D_COLOR_FROM_565(color565)
Definition: d4d_scheme.h:442
Line type thin.
Definition: d4d_types.h:293
#define D4D_ENDIAN_BIG
Constant for Big Endianism.
Definition: d4d_base.h:183
#define D4D_COLOR_FROM_888(color888)
Definition: d4d_scheme.h:440
D4D driver - resistive touch screen driver function header file.
void(* D4DLCD_Send_PixelColor)(D4D_COLOR value)
The LCD driver send pixel function. The pixels will be draw on position (automaticaly incremented) se...
Definition: d4d_lldapi.h:152
void D4D_LineToXY(D4D_COOR x, D4D_COOR y, D4D_LINETYPE ltype, D4D_COLOR color)
Function draw line on the screen.
#define D4D_BMP_256KNOPAL
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
D4D_COLOR D4D_GetGreyScale(D4D_COLOR color)
Compute the grayscale color.
Definition: d4d_scheme.c:333
#define D4D_BMP_COMPRESS_MASK
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159
D4D_COLOR(* GetPxlDecoder)(struct D4D_D4DBMP_DECODE_S *pDecode)
unsigned char(* D4DLCD_SetWindow)(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
The LCD driver Set logic window function. Into this logic window will be draw pixels.
Definition: d4d_lldapi.h:150
#define GET_DATA_LONG(pBmp_dec, inc)