From: SourceForge.net <no...@so...> - 2007-06-11 17:37:19
|
Bugs item #1723362, was opened at 2007-05-22 04:24 Message generated for change (Comment added) made by hobbs You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=1723362&group_id=12997 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 40. Bitmap Images Group: obsolete: 8.4.14 Status: Open Resolution: Works For Me Priority: 8 Private: No Submitted By: Colin McDonald (cjmcdonald) Assigned to: Jeffrey Hobbs (hobbs) Summary: tkWinDraw transparent bitmap problem and fix Initial Comment: XCopyPlane in tk/win/tkWinDraw.c is used to draw bitmap images. For some image types SetBkColor and SetTextColor are set. For bitmap images with a transparent background (case 2 in the code), the SetBkColor and SetTextColor are not set. But those settings can affect the output of transparent images, in ways that are not clearly documented in MSDN. The problem is not always seen. It does not seem to affect tcl/tk core widgets which almost always draw via an off-screen pixmap. But the tktable extension legitimately draws directly to the on-screen window for performance, and can get often get corrupted transparent bitmaps - it also seems to depends on the type of wish build, what has been drawn previously, the state of ms-windows, day of the week etc. The attached tktable-bitmap1.tcl script demonstrates the problem using tktable. The second bitmap is supposed to be a red square with rounded corners, but on my system is displayed reversed. The fix is simply to reset BkColor and TextColor for transparent bitmaps, as shown in the following patch. Note that the background/foreground settings are counter-intuitive. --- tkWinDraw.c Tue May 22 11:37:46 2007 +++ tkWinDraw-update.c Tue May 22 11:38:07 2007 @@ -415,11 +415,14 @@ /* * Case 2: transparent bitmaps are handled by setting the * destination to the foreground color whenever the source - * pixel is set. + * pixel is set. We need to reset the BkColor and TextColor, + * because they affect bitmap colour mapping. */ fgBrush = CreateSolidBrush(gc->foreground); oldBrush = SelectObject(destDC, fgBrush); + SetBkColor(destDC, RGB(255,255,255)); + SetTextColor(destDC, RGB(0,0,0)); BitBlt(destDC, dest_x, dest_y, width, height, srcDC, src_x, src_y, MASKPAT); SelectObject(destDC, oldBrush); I'll attach updated source files for the current CVS HEAD and core-8-4-15 branches. I have been using the fix with tk8.14 for several weeks with no problems. ---------------------------------------------------------------------- >Comment By: Jeffrey Hobbs (hobbs) Date: 2007-06-11 10:37 Message: Logged In: YES user_id=72656 Originator: NO Can you confirm whether you see the same issue using ActiveTcl 8.4.14 and/or 8.5 on your machine? I want to know whether this may be a compilation issue, or a system-particular issue. ---------------------------------------------------------------------- Comment By: Colin McDonald (cjmcdonald) Date: 2007-06-11 04:37 Message: Logged In: YES user_id=883691 Originator: YES Well I see a difference :-) I attach a screenshot. I think that this is basically an uninitialised state problem, so where that state is obtained from and what it contains is anyone's guess, but it could well depend on the type of tcl/tk build etc. I have just tested a clean tcl/tk 8.4.15 build, using Visual Studio 2003, with the distribution makefile.vc. Default configuration, no options i.e. not threaded or anything. This is my normal build method: d:\src\tcl8.4.15\win> nmake -f makefile.vc release d:\src\tcl8.4.15\win> nmake -f makefile.vc install INSTALLDIR=d:\tcl d:\src\tk8.4.15\win> nmake -f makefile.vc release TCLDIR=d:\src\tcl8.4.15 d:\src\tk8.4.15\win> nmake -f makefile.vc install TCLDIR=d:\src\tcl8.4.15 INSTALLDIR=d:\tcl I also build tktable using it's makefile.vc. Running the tktable-bitmap1.tcl script the problem is present as shown in the screenshot.bmp, and fixed by the patch. File Added: screenshot.bmp ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2007-06-09 17:00 Message: Logged In: YES user_id=72656 Originator: NO I see no effect with this patch applied using the demo for 8.4-branch. ---------------------------------------------------------------------- Comment By: Colin McDonald (cjmcdonald) Date: 2007-05-22 04:27 Message: Logged In: YES user_id=883691 Originator: YES File Added: tkWinDraw-8.4.15.c ---------------------------------------------------------------------- Comment By: Colin McDonald (cjmcdonald) Date: 2007-05-22 04:26 Message: Logged In: YES user_id=883691 Originator: YES File Added: tkWinDraw-head.c ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=1723362&group_id=12997 |