| #pragma once |
| |
| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string.h> |
| |
| #define BLOCKROWS 3 |
| |
| #define NEXT2(x) (((x) + 1) & -2) |
| #define NEXT4(x) (((x) + 3) & -4) |
| #define FIXDPI(x) ((x) / 65536.) |
| |
| typedef long psdByte; |
| typedef unsigned short psdUint16; |
| typedef long psdPixel; |
| |
| enum { RAWDATA, RLECOMP, ZIPWITHOUTPREDICTION, ZIPWITHPREDICTION }; |
| |
| struct TPSDChannelInfo { |
| int id; |
| int comptype; |
| psdPixel rows, cols, rowbytes; |
| |
| psdByte length; |
| psdByte filepos; |
| psdByte *rowpos; |
| unsigned char *unzipdata; |
| }; |
| |
| int unpackrow(unsigned char *out, unsigned char *in, psdPixel outlen, |
| psdPixel inlen); |
| |
| void readrow(FILE *psd, TPSDChannelInfo *chan, psdPixel rowIndex, |
| unsigned char *inbuffer, unsigned char *outbuffer); |
| |
| void skipBlock(FILE *f); |
| |
| void *mymalloc(long n); |
| unsigned read2UBytes(FILE *f); |
| int read2Bytes(FILE *f); |
| long read4Bytes(FILE *f); |
| |
| int psdUnzipWithoutPrediction(unsigned char *src_buf, int src_len, |
| unsigned char *dst_buf, int dst_len); |
| int psdUnzipWithPrediction(unsigned char *src_buf, int src_len, |
| unsigned char *dst_buf, int dst_len, int row_size, |
| int color_depth); |