forked from cfeck/imagezero
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.cpp
More file actions
42 lines (36 loc) · 1.03 KB
/
Copy pathlibrary.cpp
File metadata and controls
42 lines (36 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "libiz.h"
#include "image.h"
void __stdcall IZ_Init()
{
IZ::initDecodeTable();
IZ::initEncodeTable();
}
void __stdcall IZ_ReadHeader(unsigned char *src, int srcOffset, int& width, int& height, int& dataLength)
{
// Decode image size
IZ::Image<> img;
img.setData(src + 4);
IZ::decodeImageSize(img, src + srcOffset + 4);
// Return data
dataLength = ((int*)(src + srcOffset))[0];
width = img.width();
height = img.height();
}
void __stdcall IZ_Decode(unsigned char *src, int srcOffset, unsigned char *dst)
{
IZ::Image<> img;
img.setData(dst);
IZ::decodeImageSize(img, src + srcOffset + 4);
IZ::decodeImage(img, src + srcOffset + 4);
}
int __stdcall IZ_Encode(unsigned char *src, int imgWidth, int imgHeight, unsigned char *dst, int dstOffset)
{
IZ::Image<> img;
img.setWidth(imgWidth);
img.setHeight(imgHeight);
img.setSamplesPerLine(imgWidth * 3);
img.setData(src);
unsigned char *destEnd = IZ::encodeImage(img, dst + dstOffset + 4);
// Compute and return size
return ((int*)(dst + dstOffset))[0] = destEnd - dst;
}