Home | History | Annotate | Download | only in images
      1 /*
      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 
     23 extern "C" {
     24     #include "jpeglib.h"
     25     #include "jerror.h"
     26 }
     27 
     28 #include <setjmp.h>
     29 
     30 /* Our error-handling struct.
     31  *
     32 */
     33 struct skjpeg_error_mgr : jpeg_error_mgr {
     34     jmp_buf fJmpBuf;
     35 };
     36 
     37 
     38 void skjpeg_error_exit(j_common_ptr cinfo);
     39 
     40 ///////////////////////////////////////////////////////////////////////////
     41 /* Our source struct for directing jpeg to our stream object.
     42 */
     43 struct 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  */
     60 struct 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
     72