alternative to assert
[gtkD.git] / gtkD / src / gdkpixbuf / Pixdata.d
blob513e6513bd9cda96d5100c640eb7a48aaaddb839
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-pixbuf-inline.html
26 * outPack = gdkpixbuf
27 * outFile = Pixdata
28 * strct = GdkPixdata
29 * realStrct=
30 * ctorStrct=
31 * clss = Pixdata
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_pixdata_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gdk.Pixbuf
45 * - glib.StringG
46 * - glib.Str
47 * structWrap:
48 * - GString* -> StringG
49 * - GdkPixbuf* -> Pixbuf
50 * module aliases:
51 * local aliases:
54 module gdkpixbuf.Pixdata;
56 version(noAssert)
58 version(Tango)
60 import tango.io.Stdout; // use the tango loging?
64 private import gtkc.gdkpixbuftypes;
66 private import gtkc.gdkpixbuf;
69 private import gdk.Pixbuf;
70 private import glib.StringG;
71 private import glib.Str;
76 /**
77 * Description
78 * Using GdkPixdata, images can be compiled into an application,
79 * making it unnecessary to refer to external image files at runtime.
80 * gdk-pixbuf includes a utility named gdk-pixbuf-csource, which
81 * can be used to convert image files into GdkPixdata structures suitable
82 * for inclusion in C sources. To convert the GdkPixdata structures back
83 * into GdkPixbufs, use gdk_pixbuf_from_pixdata.
85 public class Pixdata
88 /** the main Gtk struct */
89 protected GdkPixdata* gdkPixdata;
92 public GdkPixdata* getPixdataStruct()
94 return gdkPixdata;
98 /** the main Gtk struct as a void* */
99 protected void* getStruct()
101 return cast(void*)gdkPixdata;
105 * Sets our main struct and passes it to the parent class
107 public this (GdkPixdata* gdkPixdata)
109 version(noAssert)
111 if ( gdkPixdata is null )
113 int zero = 0;
114 version(Tango)
116 Stdout("struct gdkPixdata is null on constructor").newline;
118 else
120 printf("struct gdkPixdata is null on constructor");
122 zero = zero / zero;
125 else
127 assert(gdkPixdata !is null, "struct gdkPixdata is null on constructor");
129 this.gdkPixdata = gdkPixdata;
141 * Converts a GdkPixbuf to a GdkPixdata. If use_rle is TRUE, the
142 * pixel data is run-length encoded into newly-allocated memory and a
143 * pointer to that memory is returned.
144 * pixdata:
145 * a GdkPixdata to fill.
146 * pixbuf:
147 * the data to fill pixdata with.
148 * use_rle:
149 * whether to use run-length encoding for the pixel data.
150 * Returns:
151 * If ure_rle is TRUE, a pointer to the newly-allocated memory
152 * for the run-length encoded pixel data, otherwise NULL.
154 public void* fromPixbuf(Pixbuf pixbuf, int useRle)
156 // gpointer gdk_pixdata_from_pixbuf (GdkPixdata *pixdata, const GdkPixbuf *pixbuf, gboolean use_rle);
157 return gdk_pixdata_from_pixbuf(gdkPixdata, (pixbuf is null) ? null : pixbuf.getPixbufStruct(), useRle);
161 * Converts a GdkPixdata to a GdkPixbuf. If copy_pixels is TRUE or
162 * if the pixel data is run-length-encoded, the pixel data is copied into
163 * newly-allocated memory; otherwise it is reused.
164 * pixdata:
165 * a GdkPixdata to convert into a GdkPixbuf.
166 * copy_pixels:
167 * whether to copy raw pixel data; run-length encoded
168 * pixel data is always copied.
169 * error:
170 * location to store possible errors.
171 * Returns:
172 * a new GdkPixbuf.
174 public Pixbuf gdkPixbufFromPixdata(int copyPixels, GError** error)
176 // GdkPixbuf* gdk_pixbuf_from_pixdata (const GdkPixdata *pixdata, gboolean copy_pixels, GError **error);
177 return new Pixbuf( gdk_pixbuf_from_pixdata(gdkPixdata, copyPixels, error) );
181 * Serializes a GdkPixdata structure into a byte stream.
182 * The byte stream consists of a straightforward writeout of the
183 * GdkPixdata fields in network byte order, plus the pixel_data
184 * bytes the structure points to.
185 * pixdata:
186 * a valid GdkPixdata structure to serialize.
187 * stream_length_p:
188 * location to store the resulting stream length in.
189 * Returns:
190 * A newly-allocated string containing the serialized
191 * GdkPixdata structure.
193 public byte* serialize(uint* streamLengthP)
195 // guint8* gdk_pixdata_serialize (const GdkPixdata *pixdata, guint *stream_length_p);
196 return gdk_pixdata_serialize(gdkPixdata, streamLengthP);
200 * Deserializes (reconstruct) a GdkPixdata structure from a byte stream.
201 * The byte stream consists of a straightforward writeout of the
202 * GdkPixdata fields in network byte order, plus the pixel_data
203 * bytes the structure points to.
204 * The pixdata contents are reconstructed byte by byte and are checked
205 * for validity. This function may fail with GDK_PIXBUF_CORRUPT_IMAGE
206 * or GDK_PIXBUF_ERROR_UNKNOWN_TYPE.
207 * pixdata:
208 * a GdkPixdata structure to be filled in.
209 * stream_length:
210 * length of the stream used for deserialization.
211 * stream:
212 * stream of bytes containing a serialized GdkPixdata structure.
213 * error:
214 * GError location to indicate failures (maybe NULL to ignore errors).
215 * Returns:
216 * Upon successful deserialization TRUE is returned,
217 * FALSE otherwise.
219 public int deserialize(uint streamLength, byte* stream, GError** error)
221 // gboolean gdk_pixdata_deserialize (GdkPixdata *pixdata, guint stream_length, const guint8 *stream, GError **error);
222 return gdk_pixdata_deserialize(gdkPixdata, streamLength, stream, error);
226 * Generates C source code suitable for compiling images directly
227 * into programs.
228 * GTK+ ships with a program called gdk-pixbuf-csource
229 * which offers a command line interface to this function.
230 * pixdata:
231 * a GdkPixdata to convert to C source.
232 * name:
233 * used for naming generated data structures or macros.
234 * dump_type:
235 * a GdkPixdataDumpType determining the kind of C
236 * source to be generated.
237 * Returns:
238 * a newly-allocated string containing the C source form
239 * of pixdata.
241 public StringG toCsource(char[] name, GdkPixdataDumpType dumpType)
243 // GString* gdk_pixdata_to_csource (GdkPixdata *pixdata, const gchar *name, GdkPixdataDumpType dump_type);
244 return new StringG( gdk_pixdata_to_csource(gdkPixdata, Str.toStringz(name), dumpType) );