tahoma2d/toonz/sources/common/psdlib/psdutils.h

48 lines
1.6 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BLOCKROWS 3
2016-06-15 18:43:10 +12:00
#define NEXT2(x) (((x) + 1) & -2) // uguale o successivo (pad)
#define NEXT4(x) (((x) + 3) & -4) // uguale o successivo multiplo di 4 (pad)
#define FIXDPI(x) ((x) / 65536.) // fixedpt
2016-03-19 06:57:51 +13:00
typedef long psdByte;
typedef unsigned short psdUint16;
typedef long psdPixel;
2016-06-15 18:43:10 +12:00
enum { RAWDATA, RLECOMP, ZIPWITHOUTPREDICTION, ZIPWITHPREDICTION };
2016-03-19 06:57:51 +13:00
struct TPSDChannelInfo {
2016-06-15 18:43:10 +12:00
int id; // channel id
int comptype; // channel's compression type
psdPixel rows, cols, rowbytes; // computed by dochannel()
// FIXME: need depth??
psdByte length; // channel byte count in file
psdByte filepos; // file offset of channel data (AFTER compression type)
psdByte *rowpos; // row data file positions (RLE ONLY)
unsigned char *unzipdata; // uncompressed data (ZIP ONLY)
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
int unpackrow(unsigned char *out, unsigned char *in, psdPixel outlen,
psdPixel inlen);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void readrow(FILE *psd, TPSDChannelInfo *chan, psdPixel rowIndex,
unsigned char *inbuffer, unsigned char *outbuffer);
2016-03-19 06:57:51 +13:00
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,
2016-06-15 18:43:10 +12:00
unsigned char *dst_buf, int dst_len);
2016-03-19 06:57:51 +13:00
int psdUnzipWithPrediction(unsigned char *src_buf, int src_len,
2016-06-15 18:43:10 +12:00
unsigned char *dst_buf, int dst_len, int row_size,
int color_depth);