Resizing view from cvShowImage - c++

I don't want to resize the entire image structure, but the images I am working with are too large to easily view with cvShowImage. Is there a way to resize their view within the window created by cvShowImage?

No there isn't, you will have to create a new image structure and use cvResize.

Related

Get window icon, put it on canvas, overlay image, save as ico (WinXP and Win7)

Right now I change the icon of a window with this code.
What I want to do though is get the current icon in use by a window. Then put it on a canvas. Then put another image on that (a badge) then save it as ico.
Never tried that, however the follow should work in general (with a lot of fiddling)
WM_GETICON to get the big and small icon.
Convert the icon to something the loader can understand (aka. either a BITMAP or ICO). E.g. How can I save HICON to an .ico file?
Load the image. E.g. Javascript: Render PNG stored as Uint8Array onto Canvas element without Data URI
canvas.drawImage
canvas.mozGetAsFile (Blob) or canvas.mozFetchAsStream (nsIInputStream) using the image/vnd.microsoft.icon mime.
Take the resulting data and reconstruct an icon.
LookupIconIdFromDirectoryEx and CreateIconFromResourceEx
WM_SETICON

Resize of SDI frame

I want to resize the frame window in a SDI application to a given dimension of the child view window (I want the frame to fit the dimensions of an image). Can anyone describe an (elegant) solution to finding the relation between the child view client size and the frame window size without actually resizing the window?
Currently I am using GetParentFrame()->MoveWindow(,,,) to resize the frame window. I already tried to observe the difference between GetParentWindow()->GetClientRect() and GetParentWindow()->GetWindowRect() but it does not help.
Have a look at CWnd::CalcWindowRect. It computes the size of the window required to hold a given client area. I've never used it so I don't know how it deals with toolbars, etc. but I think it can be a good starting point.

Need a way to display image and draw on the image in Visual C++

The current way that I found was to make a bitmap and paint it into a picturebox,
but there it is very slow when trying to scroll the panel (the picturebox is inside a scrollable panel).
Is there a better way to achieve this functionality?
Load the bitmap only when your picture box is created, then leave it in memory until the picture box is destroyed. Loading the bitmap every time OnPaint is called will destroy performance.
Also make sure you aren't re-painting your bitmap if you receive a WM_PAINT message and nothing has changed.
That image size, 1500x2000 will be slow. How about resizing it to 25% to show a preview and if a user wishes to see the whole image give them an alert it may take some time.

How can you make buttons on a MSVS C++ CToolBar larger along with their images?

We have a touch screen, and the toolbar is too small to hit with my meaty fingers. Is there an easy way I can have an option to make the toolbar buttons bigger and easier to hit?
So far I've attempted a few things:
m_toolbar.SetSizes( CSize(64,64), CSize(50,50) );
m_toolbar.SetSizes( CSize(64,64), CSize(50,50) );
m_toolbar.GetToolBarCtrl().SetButtonWidth( 64, 64 );
m_toolbar.GetToolBarCtrl().SetButtonSize( CSize(64, 64) );
None of these approaches stretches the images as well. The buttons get larger, and are fully functional, but the images do not overlap the buttons the way they normally would. I would prefer to keep a single image list for the icons, and have the images stretched to fit.
At toolbar creation time, create an empty CImageList with size 64x64 (let's call it large). Load the original image list from resources (we call it small).
Iterate over each image in small and copy/resize it to large.
Then assign large to your toolbar. Somewhat cumbersome bui should work.
HTH,
As far as I know there is no way to make images resize with the size of the buttons. MFC applications use bmp and not vectorial images.
So you will have to supply a bmp images with the disired sizes.
You can use a CImageList and SetImageList to set the images but then you will have to
initialize images there with the disired size also.

How could I insert a bitmap or other image objects in a CListCtrl in MFC?

I want to list the thumbnails of a set of photos in a listctrl. But the only way to achieve this is to use the setImageList method to bind a image list to the CListCtrl object and insert items like this: InsertItem (int nItem, LPCTSTR lpszitem, int nImage). I also must modify the listctrl's style by ModifyStyle(LVS_TYPEMASK, LVS_ICON) to force it to display the icon of each item.
I don't think this approach a good way to achieve my goal. Can I add items of bitmap or other image objects directly in a CListCtrl?
Thank you very much!
Why do you think it's not a good approach? Your other options are to make it an owner-drawn control and render the images yourself, or use a callback for the images via CListCtrl::SetCallbackMask.
List controls use image lists for a reason; the bitmaps are stored in a way that is most efficient for rendering the list control. You would be pretty hard pressed to do it any better.
Given that you need these sorts of extended features, sounds like you must use owner-draw. A good example is here. It doesn't show how to draw the image, but once you've got the owner-draw procedure set up you should be able to use typical BitBlts to paint the images.