File: image.h

package info (click to toggle)
slim 1.4.1-2.2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,780 kB
  • sloc: cpp: 4,383; sh: 202; makefile: 23
file content (75 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* SLiM - Simple Login Manager
	 Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
	 Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
	 Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

	 This program is free software; you can redistribute it and/or modify
	 it under the terms of the GNU General Public License as published by
	 the Free Software Foundation; either version 2 of the License, or
	 (at your option) any later version.

	 The following code has been adapted and extended from
	 xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
*/

#ifndef _IMAGE_H_
#define _IMAGE_H_

#include <X11/Xlib.h>
#include <X11/Xmu/WinUtil.h>

class Image
{
public:
	Image();
	Image(const int w, const int h, const unsigned char *rgb,
			const unsigned char *alpha);

	~Image();

	const unsigned char *getPNGAlpha() const {
		return(png_alpha);
	}
	const unsigned char *getRGBData() const {
		return(rgb_data);
	}

	void getPixel(double px, double py, unsigned char *pixel);
	void getPixel(double px, double py, unsigned char *pixel,
					unsigned char *alpha);

	int Width() const {
		return(width);
	}
	int Height() const {
		return(height);
	}

	bool Read(const char *filename);

	void Reduce(const int factor);
	void Resize(const int w, const int h);
	void Merge ( const Image *background, const int x, const int y );
	void Merge_non_crop(Image* background, const int x, const int y);
	void Crop(const int x, const int y, const int w, const int h);
	void Tile(const int w, const int h);
	void Center(const int w, const int h, const char *hex);
	void Plain(const int w, const int h, const char *hex);

	void computeShift(unsigned long mask, unsigned char &left_shift,
				unsigned char &right_shift);

	Pixmap createPixmap(Display *dpy, int scr, Window win);

private:
	int width, height, area;
	unsigned char *rgb_data;
	unsigned char *png_alpha;

	int readJpeg(const char *filename, int *width, int *height,
		unsigned char **rgb);
	int readPng(const char *filename, int *width, int *height,
		unsigned char **rgb, unsigned char **alpha);
};

#endif /* _IMAGE_H_ */