Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
libpng_image_library.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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  */
17 
18 #ifndef NET_INSTAWEB_SPRITER_LIBPNG_IMAGE_LIBRARY_H_
19 #define NET_INSTAWEB_SPRITER_LIBPNG_IMAGE_LIBRARY_H_
20 
25 
26 extern "C" {
27 #ifdef USE_SYSTEM_LIBPNG
28 #include "png.h"
29 #else
30 #include "third_party/libpng/src/png.h"
31 #endif
32 }
33 
36 
37 namespace net_instaweb {
38 namespace spriter {
39 
47  public:
49  const FilePath& base_output_path,
50  Delegate* delegate);
51  virtual ~LibpngImageLibrary() {}
52 
53  protected:
56  public:
59  png_structp png_struct, png_infop png_info, png_bytep* rows);
60  virtual ~Image();
61 
62  virtual bool GetDimensions(int* out_width, int* out_height) const;
63  const png_bytep* Rows() const;
64 
65  private:
66  png_structp png_struct_;
67  png_infop png_info_;
68  png_bytep* rows_;
69 
70  };
71 
75 
80  public:
81  Canvas(ImageLibraryInterface* lib, const Delegate* d,
82  const GoogleString& base_out_path,
83  int width, int height);
84  virtual ~Canvas();
85  virtual bool DrawImage(const ImageLibraryInterface::Image* image, int x,
86  int y);
87  virtual bool WriteToFile(const FilePath& write_path, ImageFormat format);
88 
89  private:
90  const Delegate* delegate_;
91  const GoogleString base_out_path_;
92  int width_;
93  int height_;
94  png_bytep* rows_;
95 
96  };
97 
98  virtual ImageLibraryInterface::Canvas* CreateCanvas(int width, int height);
99 
100  private:
101  friend class LibpngImageLibraryTest;
102 
103 };
104 
105 }
106 }
107 
108 #endif
Definition: image_library_interface.h:41
Definition: libpng_image_library.h:46
Images are immutable rectangular regions of pixels.
Definition: image_library_interface.h:56
virtual bool GetDimensions(int *out_width, int *out_height) const
Get the width and height of an image.
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Images are immutable rectangular regions of pixels.
Definition: libpng_image_library.h:55
Definition: image_library_interface.h:76
virtual ImageLibraryInterface::Image * ReadFromFile(const FilePath &path)
const FilePath & base_input_path()
Used by subclasses:
Definition: image_library_interface.h:108
Image(ImageLibraryInterface *lib, png_structp png_struct, png_infop png_info, png_bytep *rows)
Takes ownership of rows.
Definition: libpng_image_library.h:79
GoogleString FilePath
Definition: image_library_interface.h:45
Definition: image_library_interface.h:49