Converting a pre-defined bitmap to an image? 
Author Message
 Converting a pre-defined bitmap to an image?
The subject says it all: is there any way to
create an image from a pre-defined bitmap
(e.g. questhead) or one I define myself with
Tk_DefineBitmap?  "image create bitmap" does
not seem to allow me to use such a bitmap this
way.

The reason I wish to do this is because I have
a bunch of X bitmap files I am including in a
C file that I wish to use as game files.  They
need to be images rather than just bitmaps so
that they may have a foreground color and a
background color independant of the widget on
which they are placed, as well as the ability
to use a second bitmap for a "mask".

Does anyone have any suggestions as to how to
do this, or another approach I could take to
accomplish the same thing?  Thanks in advance
for any suggestions.

Thanks,

Karl Garrison




Mon, 04 Feb 2002 03:00:00 GMT  
 Converting a pre-defined bitmap to an image?

Quote:

> The subject says it all: is there any way to
> create an image from a pre-defined bitmap
> (e.g. questhead) or one I define myself with
> Tk_DefineBitmap?  "image create bitmap" does
> not seem to allow me to use such a bitmap this
> way.

> The reason I wish to do this is because I have
> a bunch of X bitmap files I am including in a
> C file that I wish to use as game files.  They
> need to be images rather than just bitmaps so
> that they may have a foreground color and a
> background color independant of the widget on
> which they are placed, as well as the ability
> to use a second bitmap for a "mask".

> Does anyone have any suggestions as to how to
> do this, or another approach I could take to
> accomplish the same thing?  Thanks in advance
> for any suggestions.

No, you're right, there isn't any way in Tk to
create an "image create bitmap" from a built-in
bitmap.  The best you can do is download the
source for Tk and take the bitmap files for the
built-in bitmaps and incorporate them into your
program.

You can build image create bitmaps from your
bitmap files by putting the bitmap source into
your Tcl code and using them with the -data and
-maskdata options to image create bitmap command.
That would look like this:

image create bitmap questhead -data {#define questhead_width 20
#define questhead_height 22
static unsigned char questhead_bits[] = {
   0xf8, 0x1f, 0x00, 0xac, 0x2a, 0x00, 0x56, 0x55, 0x00, 0xeb, 0xaf, 0x00,
   0xf5, 0x5f, 0x01, 0xfb, 0xbf, 0x00, 0x75, 0x5d, 0x01, 0xfb, 0xbe, 0x02,
   0x75, 0x5d, 0x05, 0xab, 0xbe, 0x0a, 0x55, 0x5f, 0x07, 0xab, 0xaf, 0x00,
   0xd6, 0x57, 0x01, 0xac, 0xab, 0x00, 0xd8, 0x57, 0x00, 0xb0, 0xaa, 0x00,
   0x50, 0x55, 0x00, 0xb0, 0x0b, 0x00, 0xd0, 0x17, 0x00, 0xb0, 0x0b, 0x00,
   0x58, 0x15, 0x00, 0xa8, 0x2a, 0x00};

Quote:
}

If you don't need to have a Tk_DefineBitmap style
bitmap, that would be the best thing to do.

-- rec --



Mon, 04 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Creating an image from a pre-defined bitmap

2. pre-defined function convert hex to decimal?

3. Converting Windows Bitmap to X bitmap format so that Tk can display it

4. Defining Bitmap in Tcl

5. How to define a bitmap within a script?

6. a small Tk extension -- adding a command to define bitmap

7. Newbis question - Pre-defined classes & modules

8. #define mimic (VHDL pre-synthesis declaration)

9. VHDL 93: Pre-Defined attributes

10. Disallowing Pre-Defined Operations

11. Units of Measure (was: Re: Disallowing Pre-Defined Operations)

12. Pre-defined math functions?

 

 
Powered by phpBB® Forum Software