blob: cc9d2466df28daaccffa8c8521ac6b104848a2f6 [file] [log] [blame]
reed@android.com6f598152010-01-21 15:34:19 +00001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkJpegUtility_DEFINED
18#define SkJpegUtility_DEFINED
19
20#include "SkImageDecoder.h"
21#include "SkStream.h"
22
23extern "C" {
24 #include "jpeglib.h"
25 #include "jerror.h"
26}
27
28#include <setjmp.h>
29
30/* Our error-handling struct.
31 *
32*/
33struct skjpeg_error_mgr : jpeg_error_mgr {
34 jmp_buf fJmpBuf;
35};
36
37
38void skjpeg_error_exit(j_common_ptr cinfo);
39
40///////////////////////////////////////////////////////////////////////////
41/* Our source struct for directing jpeg to our stream object.
42*/
43struct skjpeg_source_mgr : jpeg_source_mgr {
44 skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder);
45
46 SkStream* fStream;
47 const void* fMemoryBase;
48 size_t fMemoryBaseSize;
49 SkImageDecoder* fDecoder;
50 enum {
51 kBufferSize = 1024
52 };
53 char fBuffer[kBufferSize];
54};
55
56/////////////////////////////////////////////////////////////////////////////
57/* Our destination struct for directing decompressed pixels to our stream
58 * object.
59 */
60struct skjpeg_destination_mgr : jpeg_destination_mgr {
61 skjpeg_destination_mgr(SkWStream* stream);
62
63 SkWStream* fStream;
64
65 enum {
66 kBufferSize = 1024
67 };
68 uint8_t fBuffer[kBufferSize];
69};
70
71#endif