From dd774d76b74cb7d9c549ccd5388623ef75d55cf4 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 21 Nov 2007 03:20:48 +0000 Subject: [PATCH] dont share image data between different bitmap classes (this fixes issue when you load pixmap from .xpm, then assign it to portablenetworkgraphics class and after save to .png you'll get .xpm content inside .png file) git-svn-id: trunk@12946 - --- lcl/include/bitmap.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lcl/include/bitmap.inc b/lcl/include/bitmap.inc index 39c3e2d620..feebc49640 100644 --- a/lcl/include/bitmap.inc +++ b/lcl/include/bitmap.inc @@ -57,13 +57,14 @@ begin if Source is TBitmap then begin // TBitmap can share image data + // -> check if already shared if SrcBitmap.FImage=FImage then exit;// already sharing // MWE: dont call ChangingAll, since it will create a new image, // which we will replace anyway. // ChangingAll(Self); - + //DebugLn(['TBitMap.Assign Self=',ClassName,' Source=',Source.ClassName,' HandleAllocated=',HandleAllocated,' Canvas=',DbgSName(FCanvas)]); FTransparent := SrcBitmap.Transparent; @@ -76,9 +77,18 @@ begin // share FImage with assigned graphic FImage := SrcBitmap.FImage; FImage.Reference; + + // Paul: we can share image data only is ClassTypes are the same + // if ClassTypes are differ then we should create copy of data and free save stream + if Source.ClassType <> ClassType then + begin + UnshareImage(True); + FreeSaveStream; + end; + //DebugLn(['TBitMap.Assign B ',Width,',',Height,' ',HandleAllocated,' RefCount=',FImage.RefCount]); Changed(Self); - + Exit; end;