1 // This is part of Pico Library
\r
3 // (c) Copyright 2004 Dave, All rights reserved.
\r
4 // (c) Copyright 2006 notaz, All rights reserved.
\r
5 // Free for non-commercial use.
\r
7 // For commercial use, separate licencing terms must be obtained.
\r
10 #include "PicoInt.h"
\r
14 // Quick low-quality conversion of 320 to 176:
\r
15 int PicuQuick(unsigned short *dest,unsigned short *src)
\r
17 unsigned short *end=NULL;
\r
19 src+=13; end=src+290;
\r
25 *dest++=*src; src+=2;
\r
26 *dest++=*src; src+=2;
\r
28 *dest++=*src; src+=2;
\r
29 *dest++=*src; src+=2;
\r
36 // Shrink the pixels in src/srcLen, to the screen line pointed to by dest/destLen
\r
37 int PicuShrink(unsigned short *dest,int destLen,unsigned short *src,int srcLen)
\r
39 unsigned short *end=NULL;
\r
40 int bias=0,pa=0,sub=0;
\r
47 pa=*src++; bias-=sub;
\r
48 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }
\r
49 *dest++=(unsigned short)pa;
\r
51 pa=*src++; bias-=sub;
\r
52 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }
\r
53 *dest++=(unsigned short)pa;
\r
60 // same thing, only reversed (dest is in pre-decremental mode)
\r
61 int PicuShrinkReverse(unsigned short *dest,int destLen,unsigned short *src,int srcLen)
\r
63 unsigned short *end=NULL;
\r
64 int bias=0,pa=0,sub=0;
\r
71 pa=*src++; bias-=sub;
\r
72 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }
\r
73 *(--dest)=(unsigned short)pa;
\r
75 pa=*src++; bias-=sub;
\r
76 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }
\r
77 *(--dest)=(unsigned short)pa;
\r
84 int PicuMerge(unsigned short *dest,int destLen,unsigned short *src,int srcLen)
\r
86 unsigned short *end=NULL;
\r
87 int bias=0,pa=0,mask=PicuAnd,sub=0;
\r
94 pa=*src++; bias-=sub;
\r
95 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }
\r
96 pa&=mask; pa+=(*dest)&mask; pa>>=1;
\r
97 *dest++=(unsigned short)pa;
\r
99 pa=*src++; bias-=sub;
\r
100 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }
\r
101 pa&=mask; pa+=(*dest)&mask; pa>>=1;
\r
102 *dest++=(unsigned short)pa;
\r