Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
958 leency 1
#include "..\kosSyst.h"
2
#include "pcx.h"
3
 
4
int PCXFile::LoadPCXFile(Byte* filebuff, Dword filesize)
5
{
6
  memcpy((Byte*)&Pcx_head,(Byte*)filebuff,sizeof(PCXHeader));
7
 
8
  int state=0;
9
  if (Pcx_head.bManufacturer==0x0a && Pcx_head.bVersion==0x05)
10
  {
11
    width=Pcx_head.dwWidth-Pcx_head.dwX+1;
12
    height=Pcx_head.dwHeight-Pcx_head.dwY+1;
13
    buffer=kos_GetMemory(width*height*3);
14
 
15
    Byte* pPal=filebuff+filesize-768;
16
    Byte* pImg=filebuff+128;
17
    Byte* cBuffer=(Byte*)buffer;
18
    if (Pcx_head.bNPlanes==1)
19
    {
20
      /* 8-bit decoding */
21
      Dword y,i;
22
      Byte  cur_byte,counter;
23
      Dword cWidth;
24
 
25
      for(y=0;y
26
      {
27
        cWidth=width;
28
        while(cWidth!=0)
29
        {
30
          cur_byte=*(pImg); pImg++;
31
          counter=1;
32
          if (cur_byte>=192)
33
          {
34
            counter=(cur_byte & 0x3F);
35
            cur_byte=*(pImg); pImg++;
36
          }
37
          for(i=0;i
38
          {
39
            *(cBuffer+0)=(pPal[cur_byte*3+0]);
40
            *(cBuffer+1)=(pPal[cur_byte*3+1]);
41
            *(cBuffer+2)=(pPal[cur_byte*3+2]);
42
            cBuffer=cBuffer+3;
43
            cWidth--;
44
          }
45
        }
46
      }
47
    } else if (Pcx_head.bNPlanes==3) {
48
      /* 24-bit decoding */
49
      state=1;
50
    }
51
  } else {
52
    state=1;
53
  }
54
  return state;
55
}