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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TIEBitmap creates Access Violation
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - Dec 09 2016 :  15:15:20  Show Profile  Reply
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?

PeterPanino

933 Posts

Posted - Dec 09 2016 :  15:27:17  Show Profile  Reply
Even when I use IECanvas instead of Canvas I get an AV!

CharMap.IECanvas.Brush.Style := bsSolid;
Go to Top of Page

PeterPanino

933 Posts

Posted - Dec 10 2016 :  05:53:37  Show Profile  Reply
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 ? ? ?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Dec 10 2016 :  09:37:07  Show Profile  Reply
"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
Go to Top of Page

PeterPanino

933 Posts

Posted - Dec 10 2016 :  12:02:47  Show Profile  Reply
 
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.
Go to Top of Page

xequte

38611 Posts

Posted - Dec 11 2016 :  03:49:18  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: