Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scanline_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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_UTILS_H_
20 #define PAGESPEED_KERNEL_IMAGE_SCANLINE_UTILS_H_
21 
22 #include <cstddef>
26 
27 namespace net_instaweb {
28 class MessageHandler;
29 }
30 
31 namespace pagespeed {
32 
33 namespace image_compression {
34 
36 
43 size_t GetNumChannelsFromPixelFormat(PixelFormat format,
44  MessageHandler* handler);
45 
48 struct PaletteRGBA {
49  uint8 red_;
50  uint8 green_;
51  uint8 blue_;
52  uint8 alpha_;
53 };
54 
60  public:
61  explicit ScanlineStreamInput(MessageHandler* handler)
62  : data_(NULL), length_(0), offset_(0),
63  message_handler_(handler) {
64  }
65 
66  void Reset() {
67  data_ = NULL;
68  length_ = 0;
69  offset_ = 0;
70  }
71 
72  void Initialize(const void* image_buffer, size_t buffer_length) {
73  data_ = static_cast<const char*>(image_buffer);
74  length_ = buffer_length;
75  offset_ = 0;
76  }
77 
78  void Initialize(const GoogleString& image_string) {
79  data_ = static_cast<const char*>(image_string.data());
80  length_ = image_string.length();
81  offset_ = 0;
82  }
83 
84  const char* data() {
85  return data_;
86  }
87  size_t length() {
88  return length_;
89  }
90  size_t offset() {
91  return offset_;
92  }
93  void set_offset(size_t val) {
94  offset_ = val;
95  }
96  MessageHandler* message_handler() {
97  return message_handler_;
98  }
99 
100  private:
101  const char* data_;
102  size_t length_;
103  size_t offset_;
104  MessageHandler* message_handler_;
105 };
106 
114 bool ExpandPixelFormat(size_t num_pixels, PixelFormat src_format,
115  int src_offset, const uint8_t* src_data,
116  PixelFormat dst_format, int dst_offset,
117  uint8_t* dst_data, MessageHandler* handler);
118 
119 }
120 
121 }
122 
123 #endif
Definition: scanline_utils.h:48
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: message_handler.h:39