Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
jpeg_reader.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
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 
18 
19 #ifndef PAGESPEED_KERNEL_IMAGE_JPEG_READER_H_
20 #define PAGESPEED_KERNEL_IMAGE_JPEG_READER_H_
21 
22 #include <cstddef>
27 
28 struct jpeg_decompress_struct;
29 struct jpeg_error_mgr;
30 
31 namespace net_instaweb {
32 class MessageHandler;
33 }
34 
35 namespace pagespeed {
36 
37 namespace image_compression {
38 
40 
41 struct JpegEnv;
42 
57 class JpegReader {
58  public:
59  explicit JpegReader(MessageHandler* handler);
60  ~JpegReader();
61 
62  jpeg_decompress_struct *decompress_struct() const { return jpeg_decompress_; }
63 
64  void PrepareForRead(const void* image_data, size_t image_length);
65 
66  private:
67  jpeg_decompress_struct *jpeg_decompress_;
68  jpeg_error_mgr *decompress_error_;
69  MessageHandler* message_handler_;
70 
71 
72 };
73 
78  public:
79  explicit JpegScanlineReader(MessageHandler* handler);
80  virtual ~JpegScanlineReader();
81  virtual bool Reset();
82 
85  virtual ScanlineStatus InitializeWithStatus(const void* image_buffer,
86  size_t buffer_length);
87 
89  virtual ScanlineStatus ReadNextScanlineWithStatus(void** out_scanline_bytes);
90 
92  virtual size_t GetBytesPerScanline() { return bytes_per_row_; }
93 
94  virtual bool HasMoreScanLines() { return (row_ < height_); }
95  virtual PixelFormat GetPixelFormat() { return pixel_format_; }
96  virtual size_t GetImageHeight() { return height_; }
97  virtual size_t GetImageWidth() { return width_; }
98  virtual bool IsProgressive() { return is_progressive_; }
99 
100  private:
101  JpegEnv* jpeg_env_;
102  unsigned char* row_pointer_[1];
103  PixelFormat pixel_format_;
104  size_t height_;
105  size_t width_;
106  size_t row_;
107  size_t bytes_per_row_;
108  bool was_initialized_;
109  bool is_progressive_;
110  MessageHandler* message_handler_;
111 
112 
113 };
114 
115 }
116 
117 }
118 
119 #endif
virtual bool HasMoreScanLines()
Returns true if there are more scanlines to read.
Definition: jpeg_reader.h:94
Definition: jpeg_reader.h:57
Definition: scanline_status.h:93
virtual size_t GetBytesPerScanline()
Return the number of bytes in a row (without padding).
Definition: jpeg_reader.h:92
virtual PixelFormat GetPixelFormat()
Returns the pixel format that need to be used by writer.
Definition: jpeg_reader.h:95
virtual size_t GetImageHeight()
Returns the height of the image.
Definition: jpeg_reader.h:96
virtual bool IsProgressive()
Definition: jpeg_reader.h:98
virtual size_t GetImageWidth()
Returns the width of the image.
Definition: jpeg_reader.h:97
Definition: message_handler.h:39
virtual ScanlineStatus ReadNextScanlineWithStatus(void **out_scanline_bytes)
Return the next row of pixels.
virtual ScanlineStatus InitializeWithStatus(const void *image_buffer, size_t buffer_length)