comparison Plugins/Visualization/paranormal/pn/pnimage.h @ 1507:0c5fdcf3f947 trunk

[svn] - incomplete stuff
author nenolod
date Sun, 06 Aug 2006 01:53:29 -0700
parents
children
comparison
equal deleted inserted replaced
1506:2a8e193c07a6 1507:0c5fdcf3f947
1 /* Paranormal - A highly customizable audio visualization library
2 * Copyright (C) 2001 Jamie Gennis <jgennis@mindspring.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __PN_IMAGE_H__
20 #define __PN_IMAGE_H__
21
22 #include <glib.h>
23 #include "pnobject.h"
24
25 G_BEGIN_DECLS
26
27 typedef enum
28 {
29 PN_BLEND_MODE_IGNORE, /* Ignore the source image */
30 PN_BLEND_MODE_REPLACE, /* Replace the destination image with the source */
31 PN_BLEND_MODE_5050, /* Use the mean of the source and destination images */
32 PN_BLEND_MODE_LAST /* INVALID */
33 } PnBlendMode;
34 extern const gchar *pn_image_blend_mode_strings[];
35 extern const guint pn_image_blend_mode_count;
36
37 #define PN_TYPE_IMAGE (pn_image_get_type ())
38 #define PN_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PN_TYPE_IMAGE, PnImage))
39 #define PN_IMAGE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), PN_TYPE_IMAGE, PnImageClass))
40 #define PN_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PN_TYPE_IMAGE))
41 #define PN_IS_IMAGE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), PN_TYPE_IMAGE))
42 #define PN_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PN_TYPE_IMAGE, PnImageClass))
43
44 /* Member access macros */
45 #define PN_IMAGE_PITCH(obj) (PN_IMAGE (obj)->pitch)
46 #define PN_IMAGE_WIDTH(obj) (PN_IMAGE (obj)->width)
47 #define PN_IMAGE_HEIGHT(obj) (PN_IMAGE (obj)->height)
48 #define PN_IMAGE_IMAGE_BUF(obj) (PN_IMAGE (obj)->image_buffer)
49 #define PN_IMAGE_XFORM_BUF(obj) (PN_IMAGE (obj)->transform_buffer)
50
51 /* This is to help with passing just the PnImage part of a
52 * PnImage (e.g. to assembly code)
53 */
54 #define PN_IMAGE_START(obj) (G_STRUCT_MEMBER_P (obj, G_STRUCT_OFFSET (PnImage, pitch)))
55
56 typedef struct _PnColor PnColor;
57
58 struct _PnColor
59 {
60 guint8 red;
61 guint8 green;
62 guint8 blue;
63 guint8 unused;
64 };
65
66 typedef struct _PnImage PnImage;
67 typedef struct _PnImageClass PnImageClass;
68
69 struct _PnImage
70 {
71 PnObject parent;
72
73 /* The width of the image buffers in bytes */
74 guint pitch;
75
76 /* The dimensions of the valid image area in pixels */
77 guint width;
78 guint height;
79
80 /* The pixel bleding modes to be used when rendering individual
81 * pixels and when applying the transform buffer to the
82 * image buffer
83 */
84 PnBlendMode render_mode;
85 PnBlendMode transform_mode;
86
87 /* The pixel buffers */
88 PnColor *image_buffer;
89 PnColor *transform_buffer;
90 };
91
92 struct _PnImageClass
93 {
94 PnObjectClass parent_class;
95 };
96
97 /* Creators */
98 GType pn_image_get_type (void);
99 PnImage *pn_image_new (void);
100 PnImage *pn_image_new_with_size (guint width,
101 guint height);
102
103 /* Accessors */
104 void pn_image_set_size (PnImage *image,
105 guint width,
106 guint height);
107 guint pn_image_get_width (PnImage *image);
108 guint pn_image_get_height (PnImage *image);
109 guint pn_image_get_pitch (PnImage *image);
110 void pn_image_set_render_mode (PnImage *image,
111 PnBlendMode render_mode);
112 void pn_image_set_transform_mode (PnImage *image,
113 PnBlendMode transform_mode);
114 PnColor *pn_image_get_image_buffer (PnImage *image);
115 PnColor *pn_image_get_transform_buffer (PnImage *image);
116
117 /* Actions */
118 void pn_image_render_pixel (PnImage *image,
119 guint x,
120 guint y,
121 PnColor color);
122 void pn_image_render_pixel_by_offset (PnImage *image,
123 guint offset,
124 PnColor color);
125 void pn_image_render_line (PnImage *image,
126 guint x0,
127 guint y0,
128 guint x1,
129 guint y1,
130 PnColor color);
131 void pn_image_apply_transform (PnImage *image);
132 void pn_image_render_image (PnImage *image,
133 PnImage *src,
134 PnBlendMode blend_mode);
135
136 #endif /* __PN_IMAGE_H__ */