Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
image_resizer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 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_IMAGE_RESIZER_H_
20 #define PAGESPEED_KERNEL_IMAGE_IMAGE_RESIZER_H_
21 
22 #include <cstddef>
29 
30 namespace pagespeed {
31 
32 namespace image_compression {
33 
35 
36 class ResizeRow;
37 class ResizeCol;
38 
51  public:
52  explicit ScanlineResizer(MessageHandler* handler);
53  virtual ~ScanlineResizer();
54 
57  size_t output_width,
58  size_t output_height);
59 
63  virtual ScanlineStatus ReadNextScanlineWithStatus(void** out_scanline_bytes);
64 
66  virtual bool Reset();
67 
69  virtual size_t GetBytesPerScanline() {
70  return static_cast<size_t>(elements_per_row_);
71  }
72 
75  virtual bool HasMoreScanLines();
76 
78  virtual size_t GetImageHeight() {
79  return static_cast<size_t>(height_);
80  }
81 
83  virtual size_t GetImageWidth() {
84  return static_cast<size_t>(width_);
85  }
86 
88  virtual PixelFormat GetPixelFormat() {
89  return reader_->GetPixelFormat();
90  }
91 
93  virtual bool IsProgressive() {
94  return reader_->IsProgressive();
95  }
96 
99  virtual ScanlineStatus InitializeWithStatus(const void* image_buffer,
100  size_t buffer_length);
101 
102  static const size_t kPreserveAspectRatio = 0;
103 
104  private:
105  ScanlineReaderInterface* reader_;
110 
112  int width_;
113  int height_;
114  int elements_per_row_;
115 
118  int bytes_per_buffer_row_;
119  MessageHandler* message_handler_;
120 
121 
122 };
123 
124 }
125 
126 }
127 
128 #endif
virtual ScanlineStatus InitializeWithStatus(const void *image_buffer, size_t buffer_length)
Definition: image_resizer.h:50
Definition: scanline_status.h:93
virtual size_t GetImageWidth()
Returns the width of the image.
Definition: image_resizer.h:83
virtual PixelFormat GetPixelFormat()=0
Returns the pixel format that need to be used by writer.
virtual size_t GetBytesPerScanline()
Returns number of bytes required to store a scanline.
Definition: image_resizer.h:69
virtual bool Reset()
Resets the resizer to its initial state. Always returns true.
virtual size_t GetImageHeight()
Returns the height of the image.
Definition: image_resizer.h:78
virtual PixelFormat GetPixelFormat()
Returns the pixel format of the image.
Definition: image_resizer.h:88
virtual bool IsProgressive()
Returns true if the image is encoded in progressive / interlacing format.
Definition: image_resizer.h:93
Definition: message_handler.h:39
virtual ScanlineStatus ReadNextScanlineWithStatus(void **out_scanline_bytes)
bool Initialize(ScanlineReaderInterface *reader, size_t output_width, size_t output_height)
Initializes the resizer with a reader and the desired output size.