Bitmap Embedding

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Bitmap Embedding

Nicolas Cannasse
Hi,

Starting with r3877, it is now possible to embed bitmaps directly from
haXe code in flash9+ :

@:bitmap("file.png") class File extends flash.display.BitmapData {
}

Then you can instantiate it with :

new File(0,0)

Enjoy !
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Bitmap Embedding

singmajesty
This sounds very cool!


Do you think it might be possible to support this feature using a  
variable-style declaration, as well? I'm not sure if my syntax is right,  
but here's an example of what it might look like:



@:bitmap ("file.png")
private var File:Class <BitmapData>;




On Sun, 31 Jul 2011 11:57:40 -0700, Nicolas Cannasse  
<[hidden email]> wrote:

> Hi,
>
> Starting with r3877, it is now possible to embed bitmaps directly from  
> haXe code in flash9+ :
>
> @:bitmap("file.png") class File extends flash.display.BitmapData {
> }
>
> Then you can instantiate it with :
>
> new File(0,0)
>
> Enjoy !
> Nicolas

--
haXe - an open source web programming language
http://haxe.org
alx
Reply | Threaded
Open this post in threaded view
|

Bitmap Embedding

alx
In reply to this post by Nicolas Cannasse
Goodbye swfmill, at least for this c:

Can we do something like:

@:macro {
 for each file in dir {
   @:bitmap ....
 }
}

       ?

On Sunday, July 31, 2011, Nicolas Cannasse <[hidden email]> wrote:
> Hi,
>
> Starting with r3877, it is now possible to embed bitmaps directly from haXe code in flash9+ :
>
> @:bitmap("file.png") class File extends flash.display.BitmapData {
> }
>

> Then you can instantiate it with :
>
> new File(0,0)
>
> Enjoy !
> Nicolas
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: Bitmap Embedding

Lee Sylvester

If we could do the same with fonts and audio, I’d be a happy chappy indeed :D

 

Lee

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of alx
Sent: 31 July 2011 21:11
To: The haXe compiler list
Subject: [haXe] Bitmap Embedding

 

Goodbye swfmill, at least for this c:

Can we do something like:

@:macro {
 for each file in dir {
   @:bitmap ....
 }
}

       ?

On Sunday, July 31, 2011, Nicolas Cannasse <[hidden email]> wrote:


> Hi,
>
> Starting with r3877, it is now possible to embed bitmaps directly from haXe code in flash9+ :
>
> @:bitmap("file.png") class File extends flash.display.BitmapData {
> }
>
> Then you can instantiate it with :
>
> new File(0,0)
>
> Enjoy !
> Nicolas
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: Bitmap Embedding

Achmad Aulia Noorhakim

Hopefully there would be one that behave like factory tag in as3.

On Aug 1, 2011 4:06 AM, "Lee Sylvester" <[hidden email]> wrote:
> If we could do the same with fonts and audio, I'd be a happy chappy indeed
> :D

>
>
>
> Lee
>
>
>
>
>
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of alx
> Sent: 31 July 2011 21:11
> To: The haXe compiler list
> Subject: [haXe] Bitmap Embedding
>
>
>
> Goodbye swfmill, at least for this c:
>
> Can we do something like:
>
> @:macro {
> for each file in dir {
> @:bitmap ....
> }
> }
>
> ?
>
> On Sunday, July 31, 2011, Nicolas Cannasse <[hidden email]>
> wrote:
>> Hi,
>>
>> Starting with r3877, it is now possible to embed bitmaps directly from
> haXe code in flash9+ :
>>
>> @:bitmap("file.png") class File extends flash.display.BitmapData {
>> }

>>
>> Then you can instantiate it with :
>>
>> new File(0,0)
>>
>> Enjoy !
>> Nicolas
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Bitmap Embedding

Mike Wiering
It would be great to have something similar to embed a binary file as
a ByteArray (instead of using -resource), like:

@:file ("file.bin") class BinFile extends ByteArray { }

Or can something like this already be done via macros?


On Mon, Aug 1, 2011 at 3:54 AM, Achmad Aulia Noorhakim <[hidden email]> wrote:

> Hopefully there would be one that behave like factory tag in as3.
>
> On Aug 1, 2011 4:06 AM, "Lee Sylvester" <[hidden email]> wrote:
>> If we could do the same with fonts and audio, I'd be a happy chappy indeed
>> :D
>>
>>
>>
>> Lee
>>
>>
>>
>>
>>
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of alx
>> Sent: 31 July 2011 21:11
>> To: The haXe compiler list
>> Subject: [haXe] Bitmap Embedding
>>
>>
>>
>> Goodbye swfmill, at least for this c:
>>
>> Can we do something like:
>>
>> @:macro {
>> for each file in dir {
>> @:bitmap ....
>> }
>> }
>>
>> ?
>>
>> On Sunday, July 31, 2011, Nicolas Cannasse <[hidden email]>
>> wrote:
>>> Hi,
>>>
>>> Starting with r3877, it is now possible to embed bitmaps directly from
>> haXe code in flash9+ :
>>>
>>> @:bitmap("file.png") class File extends flash.display.BitmapData {
>>> }
>>>
>>> Then you can instantiate it with :
>>>
>>> new File(0,0)
>>>
>>> Enjoy !
>>> Nicolas
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>>
>>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Bitmap Embedding

Nicolas Cannasse
Le 27/08/2011 04:38, Mike Wiering a écrit :
> It would be great to have something similar to embed a binary file as
> a ByteArray (instead of using -resource), like:
>
> @:file ("file.bin") class BinFile extends ByteArray { }
>
> Or can something like this already be done via macros?

Actually on SVN version resources are now stored in swf binary tags, and
you can add resources dynamically with macros.

I guess you can try the following hack : add the resource with macro,
mark your class as extern and rename it to
"_res._"+name.split(".").join("_") which is the generated resource-class.

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Bitmap Embedding

John Plsek
Is there any documentation/example on adding resources dynamically with macros?

John

On 27 August 2011 18:19, Nicolas Cannasse <[hidden email]> wrote:
Le 27/08/2011 04:38, Mike Wiering a écrit :

It would be great to have something similar to embed a binary file as
a ByteArray (instead of using -resource), like:

@:file ("file.bin") class BinFile extends ByteArray { }

Or can something like this already be done via macros?

Actually on SVN version resources are now stored in swf binary tags, and you can add resources dynamically with macros.

I guess you can try the following hack : add the resource with macro, mark your class as extern and rename it to "_res._"+name.split(".").join("_") which is the generated resource-class.


Nicolas

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Bitmap Embedding

Nicolas Cannasse
Le 27/08/2011 10:48, John Plsek a écrit :
> Is there any documentation/example on adding resources dynamically with
> macros?

haxe.macro.Context.addResource

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Bitmap Embedding

John Plsek
thanks

I think?

So, it's neko thing ... I imagined it had some relevance to flash - my mistake

On 27 August 2011 20:11, Nicolas Cannasse <[hidden email]> wrote:
Le 27/08/2011 10:48, John Plsek a écrit :

Is there any documentation/example on adding resources dynamically with
macros?

haxe.macro.Context.addResource


Nicolas

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Bitmap Embedding

Jan_Flanders


On Sat, Aug 27, 2011 at 2:31 PM, John Plsek <[hidden email]> wrote:
thanks

I think?

So, it's neko thing ... I imagined it had some relevance to flash - my mistake


 
I have no idea about adding resources dynamically with haxe.macro.Context.addResource for the swf target but you could (ab)use the native meta tag for it:

build.hxml: -resource haxe.png@logo
Main.hx:  @:native("_res._logo") extern class MyByteArray extends flash.utils.ByteArray{}

Adding @:bytearray to the compiler shouldn't be too hard since the asset is already embedded as a DefineBinaryData tag and there is already @:bitmap, and these don't differ much in implementation.

Jan

--
haXe - an open source web programming language
http://haxe.org