[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Loading XBM cursors?



Jan Ekholm wrote:
> 
> Hi all,
> 
> I tried to load into our game a few custom cursors. They are all in XBM
> files, so I tried to use:
> 
> pygame.cursors.load_xbm(file,mask)
> 
> but the function fails with:
> 
>   File "/usr/local/lib/python2.0/site-packages/pygame/cursors.py", line
> 174, in load_xbm
>     info = tuple([int(curs[x].split()[-1]) for x in range(4)])
> ValueError: invalid literal for int(): {
> 
> I can't say I understand what goes on there... Maybe the funtion assumes
> another (binary) format that can be decoded with the above function? The
> XBM file I try to load is composed of the following files (data and mask):
> 
> #define cursors-map-point-001_width 32
> #define cursors-map-point-001_height 32
> static char cursors-map-point-001_bits[] = {
>   0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
>   0x73, 0x00, 0x00, 0x00, 0xe3, 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x00,
>   0x83, 0x03, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x03, 0x0e, 0x00, 0x00,
>   0x03, 0x1c, 0x00, 0x00, 0x03, 0x38, 0x00, 0x00, 0x03, 0x70, 0x00, 0x00,
>   0x03, 0xe0, 0x00, 0x00, 0x03, 0xc0, 0x01, 0x00, 0x03, 0x80, 0x03, 0x00,
>   0x0b, 0x00, 0x07, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x1c, 0x00,
>   0x13, 0x00, 0x38, 0x00, 0x03, 0x00, 0x30, 0x00, 0x0b, 0x00, 0x30, 0x00,
>   0x03, 0xc0, 0x3f, 0x00, 0x4b, 0xc0, 0x3f, 0x00, 0x83, 0x01, 0x03, 0x00,
>   0x8b, 0x01, 0x03, 0x00, 0xa3, 0x01, 0x03, 0x00, 0x83, 0x01, 0x03, 0x00,
>   0xff, 0x01, 0x03, 0x00, 0xff, 0x01, 0x03, 0x00, 0x80, 0x01, 0x03, 0x00,
>   0x80, 0xff, 0x03, 0x00, 0x80, 0xff, 0x03, 0x00 };
> 
> #define cursors-map-point-mask-001_width 32
> #define cursors-map-point-mask-001_height 32
> static char cursors-map-point-mask-001_bits[] = {
>   0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
>   0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00,
>   0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
>   0xff, 0x1f, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00,
>   0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0x03, 0x00,
>   0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0x0f, 0x00, 0xff, 0xff, 0x1f, 0x00,
>   0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0x3f, 0x00,
>   0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0x03, 0x00,
>   0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x03, 0x00,
>   0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x03, 0x00, 0x80, 0xff, 0x03, 0x00,
>   0x80, 0xff, 0x03, 0x00, 0x80, 0xff, 0x03, 0x00 };
> 
> Do I assume soemthing wrong about the function, or is this something fixed
> in 1.0pre? I still use 0.9, with SDL 1.1.8 (although SDL it is not used by
> the function load_xbm() at all, AFAIK.
> 
> Any hints? Anyone done this? If it's fixed in 1.0 I'll go download it
> right away...

For me it looks like all 4 #define should be on top.

HTH,
Niki Spahiev
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org