Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gif_square.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 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_GIF_SQUARE_H_
20 #define PAGESPEED_KERNEL_IMAGE_GIF_SQUARE_H_
21 
22 #include <cstddef>
23 #include <vector>
24 
27 
28 extern "C" {
29 #include "third_party/giflib/lib/gif_lib.h"
30 }
31 
32 namespace net_instaweb {
33 class MessageHandler;
34 }
35 
36 namespace pagespeed {
37 namespace image_compression {
38 
39 class GifSquare {
40  public:
41  GifSquare(bool manual_gcb, net_instaweb::MessageHandler* handler);
42  ~GifSquare();
43 
46  bool Open(const GoogleString& filename);
47 
59  bool PrepareScreen(bool gif89, size_px width, size_px height,
60  const GifColorType* color_map, int num_colors,
61  int bg_color_idx, size_t loop_count);
62 
73  bool PutImage(size_px left, size_px top, size_px width, size_px height,
74  const GifColorType* colormap, int num_colors,
75  int color_index, int transparent_idx,
76  bool interlace, int delay_cs, int disposal_method);
77 
82  bool AnimateAllImages(int delay_cs, int transparent_idx,
83  int disposal_method);
84 
86  bool Close();
87 
88  static const size_t kNoLoopCountSpecified;
89  static const GifColorType kGifWhite;
90  static const GifColorType kGifBlack;
91  static const GifColorType kGifGray;
92  static const GifColorType kGifRed;
93  static const GifColorType kGifGreen;
94  static const GifColorType kGifBlue;
95  static const GifColorType kGifYellow;
96 
97  private:
101  bool manual_gcb_;
103  bool success_;
104  GifFileType* gif_file_;
105  int num_images_;
106  bool closed_;
107  std::vector<ColorMapObject*> colormaps_;
108 
112  bool Log(bool success, const char* prefix);
113 
116  bool Fail(const char* prefix, const char* message);
117 
118  bool CanProceed() {
119  return success_ && !closed_;
120  }
121 };
122 
123 }
124 }
125 
126 #endif
bool PrepareScreen(bool gif89, size_px width, size_px height, const GifColorType *color_map, int num_colors, int bg_color_idx, size_t loop_count)
bool Close()
Flushes and closes the GIF file.
Definition: gif_square.h:39
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
bool AnimateAllImages(int delay_cs, int transparent_idx, int disposal_method)
bool PutImage(size_px left, size_px top, size_px width, size_px height, const GifColorType *colormap, int num_colors, int color_index, int transparent_idx, bool interlace, int delay_cs, int disposal_method)
bool Open(const GoogleString &filename)
Definition: message_handler.h:39