Forum > BGRABitmap and LazPaint

Building a composite image

<< < (11/11)

J-G:
I've now tried to incorporate the creation of the polygon outlines into my main program and have mostly been successful but am now getting an 'External: ACCESS VIOLATION' error which I can't understand.

The attached image is a ScreenGrab showing the Error, along with the part of the code referenced and the Assembler window. The 'test' program has - what I consider - the same code :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---CreatePolygon;   If Clockwise then    LineCol := cssBlack  else    LineCol := cssRed;   tmp.DrawPolygonAntialias(poly,LineCol,1,BGRAPixelTransparent);   ms := TMemoryStream.Create;        // suggestion from paweld  tmp.SaveToStreamAsPng(ms);  ms.Position := 0;  Form1.T_img.Picture.LoadFromStream(ms);  ms.Free;   tmp.free;
... though naturally with some subtle differences to the variable names  -  'Outline' is now a 'record' with all the variables being part of that rather than 'Local'.  As a test I did create 'P : Array of TPointF; ' as a local and equated that to Outline.Poly before calling [tmp.DrawPolygonAntialias] but that made no difference.

Since it fails at line 467 I can't tell yet whether the 'DestT' assignment  works but that question may be redundent in the light of paweld's suggestion in the 'Z Order' question in the General Forum.

I've incorporated a 'Create CSV' routine to easily view the figures created by the CreatePolygon Proc. and they look 'good'  - well certainly no 'extraordinary' outliers.

paweld:
Not much code, but in my opinion the error occurs because you did not declare or create a tmp variable of type tbgrabitmap, ie:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure CreateOutline;var   tmp: TBGRABitmap;  ms: TMemoryStream;begin   tmp := TBGRABitmap.Create(width, height);  CreatePolygon;      If Clockwise then    Outline.Col := cssBlack  else    Outline.Col := cssRed;    tmp.DrawPolygonAntialias(Outline.poly, Outline.Col, 1, BGRAPixelTransparent);  ms := TMemoryStream.Create;        // suggestion from paweld  tmp.SaveToStreamAsPng(ms);  ms.Position := 0;  Form1.T_img.Picture.LoadFromStream(ms);  ms.Free;  tmp.Free;end;

J-G:
Arrggg !!!   >:(   -  I have declared both tmp & ms but as you rightly surmise, at the end of the Gear BODY creation I (correctly?)  do 'tmp.Free'.  When I then go on to create the 'OUTLINE' of course I need to [Create] again  :(

The program runs (again!!)  but the next problem has raised it's ugly head - - - -  The Gear Bodies are drawn but the tooth outline is not - ???   This may be down to them not being in the correct location of course but at least I can  move forward, Thanks paweld.

I'll start looking at your 'One Bitmap' option in more detail now which may solve even a bad position issue.

Navigation

[0] Message Index

[*] Previous page

Go to full version