]> git.sesse.net Git - qscale/blob - libqscale.h
Store the sampling factors explicitly in the struct, to make saving simpler.
[qscale] / libqscale.h
1 #ifndef _LIBQSCALE_H
2 #define _LIBQSCALE_H
3
4 #include <stdio.h>
5 #include "jpeglib.h"
6
7 typedef struct {
8         /* True image size */
9         unsigned width, height;
10
11         /* Component image sizes (possibly subsampled) */
12         unsigned w0, h0;
13         unsigned w1, h1;
14         unsigned w2, h2;
15
16         /* Sampling factors */
17         unsigned samp_h0, samp_v0;
18         unsigned samp_h1, samp_v1;
19         unsigned samp_h2, samp_v2;
20
21         /* The data itself */
22         JSAMPLE *data_y, *data_cb, *data_cr;
23 } qscale_img;
24
25 enum qscale_scaling_filter {
26         LANCZOS = 0,
27 };
28
29 enum qscale_jpeg_mode {
30         SEQUENTIAL = 0,
31         PROGRESSIVE = 1
32 };
33
34 qscale_img *qscale_load_jpeg(const char *filename);
35 qscale_img *qscale_load_jpeg_from_stdio(FILE *file);
36 int qscale_save_jpeg(const qscale_img *img, const char *filename, unsigned jpeg_quality, enum qscale_jpeg_mode jpeg_mode);
37
38 qscale_img *qscale_scale(qscale_img *src, unsigned width, unsigned height, unsigned samp_h0, unsigned samp_v0, unsigned samp_h1, unsigned samp_v1, unsigned samp_h2, unsigned samp_v2, enum qscale_scaling_filter scaling_filter);
39 void qscale_destroy(qscale_img *img);
40
41 #endif /* !defined(_LIBQSCALE_H) */