Re: Embedding Images

new topic     » goto parent     » topic index » view thread      » older message » newer message

Why not an 'incbin' that is like nasm.
Dan

On 6/27/05, Tony Steward <tony.steward at gmail.com> wrote:
> I convert bmp's to xpm's and put them into and include file. This then bi=
nds
> with my app.
>
> Regards
> Tony
>
> On 6/27/05, ags <guest at rapideuphoria.com> wrote:
> >
> >
> > posted by: ags <eu at 531pi.co.nz <http://531pi.co.nz>>
> >
> > Hi Gordon
> >
> > For tiny BMP images I convert them with this quick and dirty code
> > (just the onClick code for a push button)
> > (note there's an MleText called 'restxt' in the form as well)
> >
> > }}}
<eucode>
> > procedure PushButton3_onClick (integer self, integer event, sequence
> > params)--params is ()
> > sequence name
> > atom pal_len, pal_len_item
> > atom dat_len, dat_len_item
> > object bmp_h
> > sequence result
> >
> > result = "{{"
> > name = getOpenFileName(Window1, "", {"Windows Bitmap", "*.bmp"})
> > bmp_h = read_bitmap(name)
> > if sequence(bmp_h) then
> > pal_len = length(bmp_h[1])
> > for i = 1 to pal_len do
> > result &= "{" -- open palette item
> > pal_len_item = length(bmp_h[1][i])
> > for j = 1 to pal_len_item do
> > result &= sprintf("%d", {bmp_h[1][i][j]}) -- pal entry
> > if j != pal_len_item then
> > result &= "," -- comma separate unless last item
> > end if
> > end for
> > result &= "}" -- close palette item
> > if i != pal_len then
> > result &= "," -- comma separate unless last item
> > end if
> > end for
> > result &= "},{" -- now for the data
> > dat_len = length(bmp_h[2])
> > for i = 1 to dat_len do
> > result &= "{" -- open data item
> > dat_len_item = length(bmp_h[2][i])
> > for j = 1 to dat_len_item do
> > result &= sprintf("%d", {bmp_h[2][i][j]}) -- data item
> > if j != dat_len_item then
> > result &= ","
> > end if
> > end for
> > result &= "}" -- close data item
> > if i != dat_len then
> > result &= ","
> > end if
> > end for
> > result &= "}}"
> > setText(restxt, result)
> > else
> > setText(restxt, "Error")
> > end if
> >
> > end procedure
> > </eucode>
{{{

> >
> > This prompts to open a bmp file (256 colour, or 16 colour I think,
> > but not truecolour?) and it converts it to the euphoria bitmap
> > sequence suitable for passing to win32lib's createDIB()
> > (same as you would get from read_bitmap("bmp.bmp"))
> > (in fact you can probably just pretty print that data, but it was an
> > interesting exercise at the time :)
> >
> > Then I say:
> >
> > sequence bmp_src = {{34,34,53}{67,6,etc,etc -- a _huge_ line for even=
 a
> > small bmp
> > bmp = createDIB(bmp_src)
> >
> > Then you can use 'bmp' as a handle for any win32lib object requiring on=
e
> > (eg setBitmap)
> >
> > I write a lot of programs for use on a medium size LAN and it is a pain
> > having to
> > use separate resources, so for button labels and icons etc, I do this.
> >
> > Another thing to look into is euAllegro. I have used Allegro for many
> > years
> > and it's .dat file format is excellent for storing just about anything =
in
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu