Recent

Author Topic: more graphics woes  (Read 3282 times)

liewald

  • Full Member
  • ***
  • Posts: 142
more graphics woes
« on: January 30, 2019, 10:53:29 am »
Lazarus 1.8.4 r57972 FPC 3.0.4 x86_64-win64-win32/win64

Simple one this time I hope

For some reason drawing a TBGRABitmap to a form canvas is failing with no error and no image begin displayed on the canvas

simple enough code

procedure TImageform.FormPaint(Sender: TObject);
begin
   imageform.Canvas.Draw(0,0,image.Bitmap);
end;

also tried

image.draw(imageform.canvas,0,0)

Thanks in advance

Dave





circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: more graphics woes
« Reply #1 on: January 30, 2019, 08:10:07 pm »
Surprising.

Have you checked that the image contains something for example by doing image.SaveToFile ?

Regards
Conscience is the debugger of the mind

liewald

  • Full Member
  • ***
  • Posts: 142
Re: more graphics woes
« Reply #2 on: January 30, 2019, 08:35:36 pm »
Yup and I can assign it to a timage

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: more graphics woes
« Reply #3 on: January 30, 2019, 09:12:46 pm »
See this: BGRABitmap tutorial (2) - Draw the bitmap

For more info: BGRABitmap Tutorial, a 16 wiki-pages tutorial on using TBGRABitmap.

ETA

BTW, when using properties of a form inside its class you shouldn't qualify them with the name of the instance i.e. this should be enough:
Code: Pascal  [Select][+][-]
  1. procedure TImageform.FormPaint(Sender: TObject);
  2. begin
  3.    Canvas.Draw(0, 0, image.Bitmap);
  4. {or at most, Self.Canvas.Draw(...)}
  5. { Idem for:
  6.   image.draw(Canvas, 0, 0);
  7. }
  8. end;
« Last Edit: January 30, 2019, 09:25:35 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

liewald

  • Full Member
  • ***
  • Posts: 142
Re: more graphics woes
« Reply #4 on: January 30, 2019, 10:34:30 pm »
Yup that was the original code. didn't work either been at this for 2 days

only thing a bit different is that the menu making the calls is on the main form and the canvas is on a secondary form but the code is on the canvas form.

Dave

liewald

  • Full Member
  • ***
  • Posts: 142
Re: more graphics woes
« Reply #5 on: January 30, 2019, 10:41:00 pm »
This is the setup I want. here I'm using a timage rather than the canvas and it works ok but for a number of reasons I would rather use a tcanvas!

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: more graphics woes
« Reply #6 on: January 31, 2019, 07:10:37 pm »
Are you calling FormPaint ? This may not always work. Rather call Invalidate.
Conscience is the debugger of the mind

liewald

  • Full Member
  • ***
  • Posts: 142
Re: more graphics woes
« Reply #7 on: January 31, 2019, 08:43:31 pm »
will give it a try

Dave

liewald

  • Full Member
  • ***
  • Posts: 142
Re: more graphics woes
« Reply #8 on: February 11, 2019, 12:03:18 pm »
got it thanks all

 

TinyPortal © 2005-2018