View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0036955 | Lazarus | LCL | public | 2020-04-22 21:57 | 2020-09-20 20:10 |
Reporter | Michal Gawrycki | Assigned To | Juha Manninen | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Platform | Win32 | OS | Win | ||
Product Version | 2.0.9 (SVN) | ||||
Summary | 0036955: TBitmap - Invalid canvas drawing after bitmap resize | ||||
Description | If I use TBitmap.Canvas and change the bitmap size after that, using the canvas again will bring unexpected results. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | r63131 | ||||
LazTarget | - | ||||
Widgetset | |||||
Attached Files |
|
|
|
|
I checked your sample project with Laz trunk/fpc trunk, Laz fixes/fpc fixes, Laz trunk/fpc 3.04, Laz 2.8/fpc 3.04, all of them 32 bit on Win 10/64 bit, and none of these show the issue of your screenshot for me. |
|
I found the cause of problem. My IDE is compiled with the -gt option (trash local variables). If I compile IDE without this option, everything works ok. So is this a bug or expected result? |
|
Seems that -gt have shown a bug somewhere deep in TBitmap class code. Probably uninitialized local variable(s). |
|
The problem is in FillRawImageDescription(const ABitmapInfo: Windows.TBitmap; out ADesc: TRawImageDescription) from unit Win32Proc. We have "out ADesc: TRawImageDescription" parameter but not all fields are set in this procedure, so for "-gt" option they have a random value. I see two solutions: 1. Clear ADesc record at the beginning of the FillRawImageDescription procedure (eg, ADesc := Default(TRawImageDescription)) 2. Change parameter type from "out" to "var" |
|
I'm sending patch. I'm using ADesc.Init method at the top of the procedure, like in lcl/interfaces/wince/winceproc.pp. Similar changes for /lcl/interfaces/fpgui/fpguiobject.inc file which also contains this procedure. adescinit.patch (948 bytes)
Index: lcl/interfaces/fpgui/fpguiobject.inc =================================================================== --- lcl/interfaces/fpgui/fpguiobject.inc (revision 63130) +++ lcl/interfaces/fpgui/fpguiobject.inc (working copy) @@ -398,6 +398,8 @@ procedure FillRawImageDescription(const ABitmapInfo: TfpgImage; out ADesc: TRawImageDescription); begin + ADesc.Init; + ADesc.Format := ricfRGBA; ADesc.Depth := 32; // used bits per pixel Index: lcl/interfaces/win32/win32proc.pp =================================================================== --- lcl/interfaces/win32/win32proc.pp (revision 63130) +++ lcl/interfaces/win32/win32proc.pp (working copy) @@ -1127,6 +1127,8 @@ procedure FillRawImageDescription(const ABitmapInfo: Windows.TBitmap; out ADesc: TRawImageDescription); begin + ADesc.Init; + ADesc.Format := ricfRGBA; ADesc.Depth := ABitmapInfo.bmBitsPixel; // used bits per pixel |
|
Applied, thanks. The Init procedure was indeed called in other widgetsets already. Every Lazarus developer and tester should build their IDE + packages with all possible debug flags. The -gt flag is especially useful. |
|
Thanks. Closed. |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-04-22 21:57 | Michal Gawrycki | New Issue | |
2020-04-22 21:57 | Michal Gawrycki | File Added: project1.zip | |
2020-04-22 21:57 | Michal Gawrycki | File Added: bmpresize.png | |
2020-04-29 12:24 | wp | Note Added: 0122519 | |
2020-04-29 17:47 | Michal Gawrycki | Note Added: 0122528 | |
2020-04-29 19:39 | Cyrax | Note Added: 0122529 | |
2020-05-02 14:53 | Michal Gawrycki | Note Added: 0122597 | |
2020-05-09 22:42 | Michal Gawrycki | Note Added: 0122686 | |
2020-05-09 22:42 | Michal Gawrycki | File Added: adescinit.patch | |
2020-05-10 00:28 | Juha Manninen | Assigned To | => Juha Manninen |
2020-05-10 00:28 | Juha Manninen | Status | new => assigned |
2020-05-10 00:30 | Juha Manninen | Status | assigned => resolved |
2020-05-10 00:30 | Juha Manninen | Resolution | open => fixed |
2020-05-10 00:30 | Juha Manninen | Fixed in Revision | => r63131 |
2020-05-10 00:30 | Juha Manninen | LazTarget | => - |
2020-05-10 00:30 | Juha Manninen | Note Added: 0122692 | |
2020-05-10 00:33 | Juha Manninen | Note Edited: 0122692 | View Revisions |
2020-09-20 20:10 | Michal Gawrycki | Status | resolved => closed |
2020-09-20 20:10 | Michal Gawrycki | Note Added: 0125681 |