www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - image embeded as ubtye

reply okibi <okibi ratedo.com> writes:
Hello!

I've got an image converted to a d source file that contains the image as a
ubyte variable. What I'm wanting to know is how do I apply this as the image
for a button in gtkD?

I was calling the external file, like such:

Image newImg = new Image("images\\new.png");
Button newBtn = new Button();
newBtn.setImage(newImg);

How can I set the ubyte as the image?

Thanks!
Jul 30 2007
next sibling parent Frank Benoit <keinfarbton googlemail.com> writes:
 Image newImg = new Image("images\\new.png");
 Button newBtn = new Button();
 newBtn.setImage(newImg);
 
 How can I set the ubyte as the image?

If this is something like swt, you can probably use a ByteArrayStream or something like this. BTW, since the import statement of D can include external files into char[] variables at compile time, it is no more needed to generate source files for that. (you need to set the -J compiler option) ubyte[] imagesdata = cast(ubyte[]) import( "myfile.png" );
Jul 30 2007
prev sibling parent "Stewart Gordon" <smjg_1998 yahoo.com> writes:
"okibi" <okibi ratedo.com> wrote in message 
news:f8kit9$7o9$1 digitalmars.com...
 I've got an image converted to a d source file that contains the image as 
 a ubyte variable.

If the image is small enough to store in a single byte, you're lucky. Stewart.
Jul 30 2007