FreeRDP-WebConnect WebSockets gateway  1.0.0.167
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
Png.hpp
1 /* vim: set et ts=4 sw=4 cindent:
2  *
3  * FreeRDP-WebConnect,
4  * A gateway for seamless access to your RDP-Sessions in any HTML5-compliant browser.
5  *
6  * Copyright 2012 Fritz Elfert <wsgate@fritz-elfert.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #ifndef _WSGATE_PNG_H_
21 #define _WSGATE_PNG_H_
22 
23 #include <string>
24 #include <png.h>
25 
26 #include "rdpcommon.hpp"
27 
28 namespace wsgate {
29 
35  class Png {
36  public:
37  // Constructor
38  Png();
39 
40  // Destructor
41  ~Png();
42 
50  std::string GenerateFromARGB(int width, int height, uint8_t *data);
51 
52  private:
53  png_structp png_ptr;
54  png_infop info_ptr;
55  std::string ret;
56 
57  // non-copyable
58  Png(const Png &);
59  Png & operator=(const Png &);
60 
61  void PngWrite(png_bytep data, png_size_t len);
62  void PngFlush();
63  void PngFailure(bool err, const char *msg);
64 
65  // C callbacks
66  static void cbPngWrite(png_structp, png_bytep, png_size_t);
67  static void cbPngFlush(png_structp);
68  static void cbPngError(png_structp, png_const_charp);
69  static void cbPngWarn(png_structp, png_const_charp);
70  };
71 }
72 #endif