Menu

#1869 TkAqua: display issues for buttons with image with alpha

obsolete: 8.4.13
open-accepted
4
2006-06-18
2005-03-03
No

set img [image create photo -file image-with-alpha.png]
pack [button .b -image $img]

The button is not displayed, and "OpenCPicture failed"
is printed to stderr. Subsequently interacting with
the GUI results in a crash. This happens both with
TkImg and with the PNG parser I'm implementing. It
does not crash with labels.

0 com.apple.QD 0x9156d270 SetGWorld +
0x401 com.tcltk.tklibrary 0x0b079e68 TkPutImage +
0x300
2 com.tcltk.tklibrary 0x0b040950 ImgPhotoDisplay
+ 0x1043 com.tcltk.tklibrary 0x0b039700
Tk_RedrawImage + 0xb8
4 com.tcltk.tklibrary 0x0b075924 SetupBevelButton
+ 0x1385 com.tcltk.tklibrary 0x0b075694
TkMacOSXDrawControl + 0x29c
6 com.tcltk.tklibrary 0x0b074638 TkpDisplayButton
+ 0x1287 com.tcltk.tcllibrary 0x0a0678f8
TclServiceIdle + 0x68
8 com.tcltk.tcllibrary 0x0a056dac Tcl_DoOneEvent +
0x1809 com.tcltk.tklibrary 0x0b02bcf4 Tk_MainLoop
+ 0x18
10 com.tcltk.tklibrary 0x0b04936c Tk_MainEx +
0x33811 com.tcltk.wish 0x000163c4 0x1000 +
0x153c4
12 com.tcltk.wish 0x00015e80 0x1000 +
0x14e8013 dyld 0x8fe1a558
_dyld_start + 0x64

Discussion

  • Michael Kirkham

    Michael Kirkham - 2005-03-03

    Logged In: YES
    user_id=498198

    Actually it doesn't print "OpenCPicture failed" until I
    resize the window. It seems the crash is because it goes
    ahead and continues despite the failure; tossing a "return"
    in after the error message is printed seems to prevent the
    crash, although the message is still printed with any
    resizing or interaction and the button isn't displayed.

    I notice tkMacOSXMenubutton.c also makes a call to
    OpenCPicture which similarly continues after fail rather
    than returning.

     
  • Michael Kirkham

    Michael Kirkham - 2005-03-04

    Logged In: YES
    user_id=498198

    I've traced it down to the if
    ((instancePtr->masterPtr->flags & COMPLEX_ALPHA) ...) block
    of ImgPhotoDisplay(), which generates an XImage from the
    background and blends it with the image to be displayed. If
    the alternate path is used (the one used for images without
    alpha) it displays the button normally with the image and
    doesn't crash, but then of course no alpha blending is done
    anywhere.

    It seems rather wrong that it would be trying to blend with
    a generated image from the background, however - the
    background in this case is a button control that is in the
    process of being drawn.

     
  • Michael Kirkham

    Michael Kirkham - 2005-03-04
     
  • Michael Kirkham

    Michael Kirkham - 2005-03-04

    Logged In: YES
    user_id=498198

    If I comment out the ImgPhotoBlendComplexAlpha() call, so
    that in theory it should display just the background image
    that the actual image gets blended with, a rather odd thing
    results, shown in the attached image.

    Commenting out the XGetPixel/XPutPixel in IPBCA results in
    the same. It requires both the be commented out. Either
    one uncommented results in the button not being displayed at
    all, and crashing after interacting with the GUI. It seems
    to really Not Like that background image generated by
    XGetImage().

     
  • Michael Kirkham

    Michael Kirkham - 2005-03-24

    Logged In: YES
    user_id=498198

    Affects menubutton, too. I've pretty much run out of ideas.
    No matter what I try it will crash if Tk_RedrawImage() is
    called any time between OpenCPicture() and ClosePicture().
    I even tried creating a new pixmap and doing it into there
    and it still crashed.

     
  • Daniel A. Steffen

    • assigned_to: das --> wolfsuit
     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580

    Jim,
    you mentioned you were looking into nasties ;-), maybe you can help
    with this? I don't have time ATM...

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-12-01
    • priority: 5 --> 7
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-12-01

    Logged In: YES
    user_id=72656

    Tk 8.4.12-rc (ActiveTcl) did not crash, but the button
    certainly doesn't draw the image correctly, whereas the
    label does appear to. Attached is an image that underwent a
    few resizings.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-12-01

    button and label with alpha png showing drawing problem

     
  • Michael Kirkham

    Michael Kirkham - 2005-12-04

    Logged In: YES
    user_id=498198

    Confirmed current core-8-4-branch doesn't crash but does
    have drawing problems. Seems like at least part of what's
    going on here is it's offsetting the image by the distance
    from the top-left corner of the window to the top-left
    corner of the button. Thus if the window is twice as wide
    as the button, say, the left side of the image is right in
    the middle (horizontally) in the button.

     
  • Daniel A. Steffen

    • milestone: --> obsolete: 8.4.13
    • assigned_to: wolfsuit --> das
    • summary: TkAqua: crash when using buttons with image with alpha --> TkAqua: display issues for buttons with image with alpha
    • priority: 7 --> 9
    • status: open --> open-accepted
     
  • Daniel A. Steffen

    • priority: 9 --> 5
     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580

    committed fix for the incorrect positioning to HEAD and core-8-4-branch

    However alpha-blending of an image with the native button background is
    still broken:
    this is non-trivial to fix because the blending computation occurs in
    SetupBevelButton() before the native button is drawn, but the generic
    blending code assumes it can retrieve the background to blend into via
    XGetImage from the screen.

    One possible (fairly expensive) solution might be to draw the undecorated
    widget into an offscreen buffer first and take the XGetImage bg from there;
    changes to generic code will be needed to add support for getting the
    background for blending from a different source than normal.

    Please anybody feel free to have a go at this, it's not high on my list ATM...

     
  • Daniel A. Steffen

    • priority: 5 --> 4
     
MongoDB Logo MongoDB