Problem in Bitmap format 
Author Message
 Problem in Bitmap format

Iam trying to simply display a bitmap on  a button widget.
I'am on Wondows 95 and I use pbrush to create new bitmap files.
I can't display any bitmap I create, but therefore was
successful to display the built-in bitmaps which means my code
is correct. There is then a problem with the format because I
couldn't also open the built-in bitmap files with pbrush, with
the error "format...."
What software should I use then to create bitmaps that I could
display with Tk8.0?

Anyhelp is greatly appreciated.

Francois



Tue, 12 Oct 1999 03:00:00 GMT  
 Problem in Bitmap format

On Fri, 25 Apr 1997 16:49:04 -0400, francois Ziade

Quote:

>Iam trying to simply display a bitmap on  a button widget.
>I'am on Wondows 95 and I use pbrush to create new bitmap files.
>I can't display any bitmap I create, but therefore was
>successful to display the built-in bitmaps which means my code
>is correct. There is then a problem with the format because I
>couldn't also open the built-in bitmap files with pbrush, with
>the error "format...."
>What software should I use then to create bitmaps that I could
>display with Tk8.0?

>Anyhelp is greatly appreciated.

>Francois


Francois,

I've run into the same thing (using Python/Tkinter).  It seems Tk
wants bitmaps in .xbm format.  The only way I've succeeded is to use
paint shop to create the monochrome bit map, and then I wrote a python
script to take this .bmp and output a .xbm, which I can then use as

you the idea, although I just did this, so its not been tested too
much.  It seems to work with NxN (where N is a multiple of 8) images,
it I ouput a 'flipped" image from photo shop:

import string
import Image
import Numeric

name = 'histogram'
im = Image.open('d:\\python\\bmps\\%s.bmp' % name)
out = open('d:\\python\\xbms\\%s.xbm' % name, 'w+')

a = Numeric.array(im.tostring(), Numeric.UnsignedInt8)
w = im.size[0]
h = im.size[1]
num = ((w+7)/8)*h  # this should be the number of elements
                                # we write out

out.write('#define %s_width %d\n' % (name, w))
out.write('#define %s_height %d\n' % (name, h))
out.write('static unsigned char %s_bits[] = {' % name)

nw = 0
last = len(a) - 8
for i in range(0, len(a), 8):
    v = 0
    for j in range(8):
        if a[i+j]: v = v + (1<<j)
    if nw == 0:
        out.write('\n  ')
    if i == last:
        out.write(' 0x%02x}\n' % v)
    else:
        out.write(' 0x%02x,' % v)
    nw = (nw + 1) % 12

out.close()



Wed, 13 Oct 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem in Bitmap format

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

3. How to Convert X Bitmap Format to Windows Bitmap Format?

4. Bitmap header format + PTR operator

5. Bitmap header format

6. The bitmap-format

7. Bitmap for icon != bitmap for button?

8. coloured bitmap with the option -bitmap ?

9. Bitmap related problem...

10. colour bitmap with mask problem

11. Bitmap problems in MSWLogo

 

 
Powered by phpBB® Forum Software