Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scanline_interface.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_SCANLINE_INTERFACE_H_
20 #define PAGESPEED_KERNEL_IMAGE_SCANLINE_INTERFACE_H_
21 
22 #include <cstddef>
27 
28 namespace pagespeed {
29 
30 namespace image_compression {
31 
33  public:
35  virtual ~ScanlineReaderInterface() {}
36 
40  virtual bool Reset() = 0;
41 
43  virtual size_t GetBytesPerScanline() = 0;
44 
46  virtual bool HasMoreScanLines() = 0;
47 
48  virtual ScanlineStatus InitializeWithStatus(const void* image_buffer,
49  size_t buffer_length) = 0;
50  inline bool Initialize(const void* image_buffer, size_t buffer_length) {
51  return InitializeWithStatus(image_buffer, buffer_length).Success();
52  }
53 
57  void** out_scanline_bytes) = 0;
58 
61  inline bool ReadNextScanline(void** out_scanline_bytes) {
62  return ReadNextScanlineWithStatus(out_scanline_bytes).Success();
63  }
64 
66  virtual size_t GetImageHeight() = 0;
67 
69  virtual size_t GetImageWidth() = 0;
70 
72  virtual PixelFormat GetPixelFormat() = 0;
73 
77  virtual bool IsProgressive() = 0;
78 
79  private:
80 
81 };
82 
84  public:
86  virtual ~ScanlineWriterInterface() {}
87 
89  virtual ScanlineStatus InitWithStatus(const size_t width, const size_t height,
90  PixelFormat pixel_format) = 0;
91  inline bool Init(const size_t width, const size_t height,
92  PixelFormat pixel_format) {
93  return InitWithStatus(width, height, pixel_format).Success();
94  }
95 
96  virtual ScanlineStatus InitializeWriteWithStatus(const void* config,
97  GoogleString* const out) = 0;
98  inline bool InitializeWrite(const void* config,
99  GoogleString* const out) {
100  return InitializeWriteWithStatus(config, out).Success();
101  }
102 
106  const void *scanline_bytes) = 0;
107  inline bool WriteNextScanline(const void *scanline_bytes) {
108  return WriteNextScanlineWithStatus(scanline_bytes).Success();
109  }
110 
113  inline bool FinalizeWrite() {
114  return FinalizeWriteWithStatus().Success();
115  }
116 
117  private:
118 
119 };
120 
121 }
122 
123 }
124 
125 #endif
Definition: scanline_status.h:93
virtual bool HasMoreScanLines()=0
Returns true if there are more scanlines to read.
virtual size_t GetBytesPerScanline()=0
Returns number of bytes that required to store a scanline.
virtual PixelFormat GetPixelFormat()=0
Returns the pixel format that need to be used by writer.
virtual ScanlineStatus InitWithStatus(const size_t width, const size_t height, PixelFormat pixel_format)=0
Initialize the basic parameter for writing the image.
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual ScanlineStatus WriteNextScanlineWithStatus(const void *scanline_bytes)=0
virtual ScanlineStatus FinalizeWriteWithStatus()=0
Finalizes write structure once all scanlines are written.
virtual size_t GetImageHeight()=0
Returns the height of the image.
virtual ScanlineStatus ReadNextScanlineWithStatus(void **out_scanline_bytes)=0
bool ReadNextScanline(void **out_scanline_bytes)
Definition: scanline_interface.h:61
virtual size_t GetImageWidth()=0
Returns the width of the image.