The Pedigree Project  0.1
applications/winman/Png.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef TUI_PNG_H
21 #define TUI_PNG_H
22 
23 #include <png.h>
24 #include <stdint.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #include <cairo/cairo.h>
29 
30 class Png
31 {
32  public:
33  Png(const char *filename);
34  ~Png();
35 
36  void render(cairo_t *cr, size_t x, size_t y, size_t width, size_t height);
37  void renderPartial(
38  cairo_t *cr, size_t atX, size_t atY, size_t innerX, size_t innerY,
39  size_t partialWidth, size_t partialHeight, size_t scaleWidth,
40  size_t scaleHeight);
41 
42  size_t getWidth()
43  {
44  return m_nWidth;
45  }
46 
47  size_t getHeight()
48  {
49  return m_nHeight;
50  }
51 
52  private:
53  Png(const Png &);
54  Png &operator=(const Png &);
55 
56  png_structp m_PngPtr;
57  png_infop m_InfoPtr;
58  size_t m_nWidth;
59  size_t m_nHeight;
60 
61  uint8_t **m_pRowPointers;
62  uint32_t *m_pBitmap;
63 };
64 
65 #endif
Png(const char *filename)