ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TIEBitmap creates Access Violation

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Dec 09 2016 : 15:15:20
When I run my app with this code:

TestBM := TIEBitmap.Create;
TestBM.Canvas.Brush.Style := bsSolid;
TestBM.Read('colors2.bmp');


then I get an access violation!

But with this code in this sequence there is no AV:

TestBM := TIEBitmap.Create;
TestBM.Read('colors2.bmp');
TestBM.Canvas.Brush.Style := bsSolid;


Or even when I use the first sequence (which creates an AV with TIEBitmap) with TImage instead I get no AV!

1. Why does TIEBitmap create an Access Violation where TBitmap does not?

2. I need to create the Bitmap only in memory, I do not want to load anything from disk. So how can I set
TestBM.Canvas.Brush.Style := bsSolid;
without getting an AV?
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Dec 11 2016 : 03:49:18
Sorry for the confusion. For 7.0.0, we'll improve it to work more like TBitmap.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
PeterPanino Posted - Dec 10 2016 : 12:02:47
 
IECanvas is not acessible unless iIEBitmap has dimension


This should have been mentioned in the ImageEn 6.3.2 documentation ImageEn.chm under TIEBitmap.Create, since this is a behavior which differs from TBitmap where TBitmap.Create always automatically creates a canvas. Then there wouldn't have been the need to post this question on the forum.

The ImageEn documentation has a good quality, but topics which differ from analog VCL behavior should be more extensively covered.
w2m Posted - Dec 10 2016 : 09:37:07
"TestBM := TIEBitmap.Create;
TestBM.Canvas.Brush.Style := bsSolid;
TestBM.Read('colors2.bmp');
then I get an access violation!"

procedure TForm1.Button1Click(Sender: TObject);
var
  iIEBitmap: TIEBitmap;
begin
  try
    iIEBitmap := TIEBitmap.Create;
    {IECanvas is not acessible unless iIEBitmap has dimension, so set the iIEBitmap dimensions before accessing the Canvas.  Allcoate prepares space for an image with ImageWidth and ImageHeight sizes.}
    iIEBitmap.Allocate(500,500);
    iIEBitmap.Canvas.Brush.Style := bsSolid;
    iIEBitmap.Read('colors2.bmp');
    ImageEnView1.IEBitmap.Assign(iIEBitmap);
    ImageEnView1.Update;
  finally
    iIEBitmap.Free;
  end;
end;

"But with this code in this sequence there is no AV:
TestBM := TIEBitmap.Create;
TestBM.Read('colors2.bmp');
TestBM.Canvas.Brush.Style := bsSolid;"
The reason for this is because after the IEBitmap is read, the IEBitmap has dimensions and a canvas.

If you want to create a memory bitmap then set its Location to ieMemory, but be sure to call Allocate first:
iIEBitmap.Allocate(500,500);
iIEBitmap.Location := ieMemory;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
PeterPanino Posted - Dec 10 2016 : 05:53:37
This code gives me a BLACK bitmap:

MyTIEBitmap := TIEBitmap.Create;
MyTIEBitmap.Width := 500;
MyTIEBitmap.Height := 500;
MyTIEBitmap.Fill(clWhite);
MyTIEBitmap.Write('R:\test.bmp');


And This code gives me a WHITE bitmap:

MyTIEBitmap := TIEBitmap.Create(500, 500);
MyTIEBitmap.Fill(clWhite);
MyTIEBitmap.Write('R:\test.bmp');


W H Y ? ? ?

--------------------------------------------------

Similarly, this code gives me an Access Violation at run-time:

MyTIEBitmap := TIEBitmap.Create;
MyTIEBitmap.Width := 500;
MyTIEBitmap.Height := 500;
MyTIEBitmap.IECanvas.Brush.Style := bsSolid; // AV!
MyTIEBitmap.Write('R:\test.bmp');


And This code gives me NO access violation at run-time:

MyTIEBitmap := TIEBitmap.Create(500, 500);
MyTIEBitmap.IECanvas.Brush.Style := bsSolid; // No AV
MyTIEBitmap.Write('R:\test.bmp');


W H Y ? ? ?
PeterPanino Posted - Dec 09 2016 : 15:27:17
Even when I use IECanvas instead of Canvas I get an AV!

CharMap.IECanvas.Brush.Style := bsSolid;