Recent

Author Topic: Is there a BGRABitmap version of TImgView32?  (Read 4262 times)

PeteS

  • New Member
  • *
  • Posts: 14
Is there a BGRABitmap version of TImgView32?
« on: December 09, 2016, 12:58:27 pm »
Is there a canned viewer for a BGRABitmap, much like ImgView32 for the Graphics32 library?  I see the BGRAVirtualScreen component, but it doesn't have scrollbars.  What's the best way to achieve the basic functionality of ImgView32 with a BGRABitmap?

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Is there a BGRABitmap version of TImgView32?
« Reply #1 on: December 09, 2016, 01:03:32 pm »
Add a TScrollBox and put inside a TBGRAVirtualScreen?

For those don't know about the functionality of ImView32 you can put some more information?

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Is there a BGRABitmap version of TImgView32?
« Reply #2 on: December 09, 2016, 11:50:42 pm »
Indeed, a TBGRAVirtualScreen in a TScrollBox would do.

By setting the size of the TBGRAVirtualScreen to the size of the bitmap and by drawing the image in the OnRedraw event.
Conscience is the debugger of the mind

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Is there a BGRABitmap version of TImgView32?
« Reply #3 on: December 11, 2016, 12:53:42 am »
Interesting that you guys both came to the same conclusion as me: a VirtualScreen-in-ScrollBox is exactly what I did to replace the ImgView32 in Deled's raytracing form.

PeteS

  • New Member
  • *
  • Posts: 14
Re: Is there a BGRABitmap version of TImgView32?
« Reply #4 on: December 13, 2016, 03:23:21 pm »
I had thought of putting a TGBRAVirtualScreen inside a TScrollBox, but wanted to expand on that a fair bit more in a re-usable component.  So I've used a TScrollingWinControl as a base, it 'owns' a TBGRABitmap, does 'stuff' and creates a work TBGRABitmap, and draws the work BM to the canvas of the TScrollingWinControl either using either top left or centered coordinates.  At the moment the 'stuff' is scaling using TResampleMode and TResampleFilter.  By setting the properties of the scrollbars from the dimensions of the work BM all seems to work nicely.

Until I scale large bitmaps - when it becomes very slow (8x scaling on a 1000x2000 image).  I've realised that I have been very naive in simply creating a (often huge) work BM and drawing it to the canvas using BM.Draw(Canvas, offsetX, offsetY).  I think I should be extracting the area of the original BM that will be visible, doing 'stuff' on that, and drawing only that portion.  At this stage I'm struggling for the methodology that I should follow.  Any pointers?

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Is there a BGRABitmap version of TImgView32?
« Reply #5 on: December 13, 2016, 04:16:39 pm »
See the source code of LazPaint?

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Is there a BGRABitmap version of TImgView32?
« Reply #6 on: December 16, 2016, 10:42:40 pm »
- use scrollbars that are outside of the picture area, just as an information on the position
- compute the coordinates of the image after scrolling/zooming
- in the virtual screen, do a StretchPutImage using what you have computed and it will be clipped, only the visible part will actually be stretched
- when the scrollbars are scrolled, call Redraw method of the virtual screen to update it
Conscience is the debugger of the mind

regs

  • Jr. Member
  • **
  • Posts: 53
Re: Is there a BGRABitmap version of TImgView32?
« Reply #7 on: January 21, 2023, 03:46:09 pm »
I did try putting BGRAVirtualScreen into ScrollBar, but when trying to zoom in picture, by increasing its size, it starts consuming a lot of memory and quickly runs out, barely hitting somewhere 17000x17000. So what is correct way of scaling/zooming pictures in this pair?

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Is there a BGRABitmap version of TImgView32?
« Reply #8 on: January 21, 2023, 09:29:33 pm »
Nope, better not to put BGRAVirtualScreen into a scrolling area. I invite you to read my previous post. You can use scrollbars independently of an area and use them as a cursor. But in the virtual screen, you would draw with the correct scrolling.

Indeed a component could be done to handle that, and zoom as well.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018