View Issue Details

IDProjectCategoryView StatusLast Update
0036955LazarusLCLpublic2020-09-20 20:10
ReporterMichal Gawrycki Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
PlatformWin32OSWin 
Product Version2.0.9 (SVN) 
Summary0036955: TBitmap - Invalid canvas drawing after bitmap resize
DescriptionIf I use TBitmap.Canvas and change the bitmap size after that, using the canvas again will bring unexpected results.
TagsNo tags attached.
Fixed in Revisionr63131
LazTarget-
Widgetset
Attached Files

Activities

Michal Gawrycki

2020-04-22 21:57

reporter  

project1.zip (108,044 bytes)
bmpresize.png (3,781 bytes)   
bmpresize.png (3,781 bytes)   

wp

2020-04-29 12:24

developer   ~0122519

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.

Michal Gawrycki

2020-04-29 17:47

reporter   ~0122528

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?

Cyrax

2020-04-29 19:39

reporter   ~0122529

Seems that -gt have shown a bug somewhere deep in TBitmap class code. Probably uninitialized local variable(s).

Michal Gawrycki

2020-05-02 14:53

reporter   ~0122597

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"

Michal Gawrycki

2020-05-09 22:42

reporter   ~0122686

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
adescinit.patch (948 bytes)   

Juha Manninen

2020-05-10 00:30

developer   ~0122692

Last edited: 2020-05-10 00:33

View 2 revisions

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.

Michal Gawrycki

2020-09-20 20:10

reporter   ~0125681

Thanks.
Closed.

Issue History

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