Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: Kingga on January 19, 2019, 10:13:31 pm

Title: [SOLVED] TImage is being clipped.
Post by: Kingga 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 (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?
Title: Re: TImage is being clipped.
Post by: circular on January 19, 2019, 10:42:40 pm
Hmm what about TImage.Width and .Height ?
Title: Re: TImage is being clipped.
Post by: Kingga 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.
TinyPortal © 2005-2018