Recent

Author Topic: [SOLVED] TImage is being clipped.  (Read 1351 times)

Kingga

  • Newbie
  • Posts: 2
[SOLVED] TImage is being clipped.
« on: January 19, 2019, 10:13:31 pm »
I'm new to both Pascal and Lazarus and I need it for a library called php-gui.

I'm trying to add an image class to it and I'm currently doing it by using PHP Imagick and then rendering each pixel to a canvas. This is quite slow for larger images so I decided to jump into the Pascal and loaded the image like:
Code: Pascal  [Select]
  1. (objArray[objId] as TImage).Picture.LoadFromFile(jData.FindPath('params[2][0]').AsString);
After compiling and setting up the class to use this I get an image but it has been cut off.

See screenshot: https://gyazo.com/9b56faf001b5a34c00de1c2dea125d4a

I also use something which has already been built in php-gui which is defined in Pascal like:
Code: Pascal  [Select]
  1. (objArray[objId] as TImage).Picture.Bitmap.SetSize(jData.FindPath('params[2][0]').AsInteger,jData.FindPath('params[2][1]').AsInteger);
before calling the load file function.

Would anyone know what was causing this and how I can fix it?
« Last Edit: January 19, 2019, 11:21:46 pm by Kingga »

circular

  • Hero Member
  • *****
  • Posts: 3022
    • Personal webpage
Re: TImage is being clipped.
« Reply #1 on: January 19, 2019, 10:42:40 pm »
Hmm what about TImage.Width and .Height ?
Conscience is the debugger of the mind

Kingga

  • Newbie
  • Posts: 2
Re: TImage is being clipped.
« Reply #2 on: January 19, 2019, 11:20:58 pm »
It's always the simple things.
Code: Pascal  [Select]
  1. else if messageMethodName = 'image.setSize' then
  2. begin
  3.   (objArray[objId] as TImage).Width := jData.FindPath('params[2][0]').AsInteger;
  4.   (objArray[objId] as TImage).Height := jData.FindPath('params[2][1]').AsInteger;
  5. end
  6. else if messageMethodName = 'image.loadFromFile' then
  7. begin
  8.   (objArray[objId] as TImage).Picture.LoadFromFile(jData.FindPath('params[2][0]').AsString);
  9. end
  10.  

Thanks for your help.