#94 wrong getpixel / putpixel in plugins when in 15 bpp mode

v0.9.19
closed
Rendering (4)
5
2012-10-03
2007-12-13
No

This bug may be related to bug 1841123.

As I wrote in the developer mailing list, I noticed that when in 15 bpp mode, the grass and calligraphy magic tools did not work at all.

This bug is caused by plugin api struct that passes getpixel/putpixel function pointer with the color depth of the display canvas, but if this depth is different from the depth of the images used by the plugins (grass_brush and the like) then the bug appears.

I solved this bug with a dirty hack in grass.c:

include "../../src/pixels.h"

then in do_grass use getpixel32:

SDL_GetRGBA(getpixel32(img_grass, xx + src.x, yy + src.y),img_grass->format, &r, &g, &b, &a);

magic makefile must be changed to:

grass.$(SO_TYPE): src/grass.c
@echo "Building Grass magic tool"
@$(CC) $(CFLAGS) -shared -o $@ $< $(PLUGIN_LIBS) ../obj/pixels.o

The best solution IMHO would be to write a getpixel/putpixel generic function that calls the right getpixelXX function depending on the color depth of the surface that must be processed.

Discussion

  • William Kendrick

    Logged In: YES
    user_id=132410
    Originator: NO

    Duplicate of #1841123, but this bug has more details. Closing that one as a dup of this one. Thanks!

     
  • William Kendrick

    Logged In: YES
    user_id=132410
    Originator: NO

    • Fixed bug when zooming stamps in video depth other than 32bpp. (Float to int casting; also removes compiler errors.)

    • getpixel/putpixel function passed to Magic tools now pays attention to the incoming surface, rather than always using the canvas surface, to determine bitdepth. (Fixes bug where some Magic tools, e.g., Grass didn't work right on video depths other than 32bpp.)

     

Log in to post a comment.