Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: mosquito on September 28, 2021, 09:36:19 am
Title: Position BGrabitmap regarding their-dimension of another.
Post by: mosquito on September 28, 2021, 09:36:19 am
I have a BGrabitmap, this is a 800x600 background. Above, I have several BGrabitmap placed in fixed positions with a certain size, these are floating elements on the background.
Now what I want to do is resize the background and that all floating elements are re-escaled and re-positioned in proportion and keep the right aspect.
Any ideas ? I would not mind any advice, although the resize was keeping the aspect-ratio of the image. Anything is welcome.
Thanks.
Title: Re: Position BGrabitmap regarding their-dimension of another.
Post by: winni on September 28, 2021, 05:37:47 pm
Hi!
I try to understand, but:
Where do you draw on?
Is the Background_BGRAbitmap part of a BGRA component? Do you draw on it?
Winni
Title: Re: Position BGrabitmap regarding their-dimension of another.
Post by: mosquito on September 29, 2021, 10:18:22 am
Yes, sorry... I'm drawing in a bgravirtualscreen // 800x600
If it was only scale, I think with a linear interpolation could. If only distances were, you also do it. But re-positioning and scaling based on a given proportion, I think it requires some trigonometry that I do not know.
Obviously I want to resize the VirtualScreen, and that everything else maintains the original look but expanded or decreased in size and relative positions.
Title: Re: Position BGrabitmap regarding their-dimension of another.
Post by: circular on September 30, 2021, 07:58:02 am
Hello mosquito,
You could use a layered bitmap, add image originals, and then resize the the layered bitmap.
There is sample projet here: https://github.com/bgrabitmap/bgrabitmap/tree/master/test/layeroriginal
For images, you can add images, gradients or SVG. To add an image it would be those lines:
But I have a problem (I forgot to comment). The floating bitmaps are part of an Trecord, so I need to know at all times its size and position.
Not sure what you mean by TRecord. For what purpose do you need to know the coordinates?
If you want to know if a pixel is in an image, you could check that the pixel at the specified coordinate is not transparent in the layer bitmap.
Title: Re: Position BGrabitmap regarding their-dimension of another.
Post by: mosquito on October 02, 2021, 01:36:15 pm
winni: This is exactly what she was looking for, thank you very much.
circular: Floating bitmaps are transparent clicked hotspots. They are on a world map of temperatures (background). I need updated coordinates for this. For now the Winni solution works very well, but I will try to mix this with a Layered Bitmap, maybe it's more versatile.
Thanks to both.
Title: Re: Position BGrabitmap regarding their-dimension of another.
Post by: circular on October 02, 2021, 10:37:04 pm
You can use the matrix of the layer to compute the coordinates.
PointF(0,0)*bmp.LayerMatrix[layerIndex] will give you the upper-left corner PointF(originalWidth,originalHeight)*bmp.LayerMatrix[layerIndex] will give you the lower-right corner
The matrix is updated depending on the transformation you applied to the whole layered bitmap.
Title: Re: Position BGrabitmap regarding their-dimension of another.
Post by: mosquito on October 03, 2021, 04:58:47 pm
Awesome, BGRABitmap never ceases to surprise me. Thank you very much for sharing this great project and for the good price of the support. :D
Title: Re: Position BGrabitmap regarding their-dimension of another.
Post by: circular on October 03, 2021, 05:29:32 pm