My application use a .bmp file for ImageList.
To do this, I use ImageList_LoadImage macro (https://msdn.microsoft.com/fr-fr/library/windows/desktop/bb761557(v=vs.85).aspx)
I would like to scale this ImageList programmatically.
For example, my .bmp file dimension is 72x24 (3 items of 24x24 icons).
And I would like scale it to 144x46 (3 items of 48x48 icons).
I didn't find any ImageList function to scale my HIMAGELIST handle loaded from .bmp file.
I tried using LoadImage function (https://msdn.microsoft.com/en-us/library/ms648045(v=vs.85).aspx)
But it must be used with bmp file, and here I have HIMAGELIST handle.
I tried to create a new image, copying scaled icons:
ImageList_Create (with icons 48)
Enumerate icons from image list 24 with ImageList_ExtractIcon
Scale icon with DrawIconEx
Add to new image list with ImageList_AddIcon
But it fails when addin icon to new image list.
Related
I have a CListCtrl in Report View that displays a series of images (192px X 192px) that a user can click and select. When the window is resized, I can see more of the images vertically, but not horizontally. What can I do to reposition the images. I dynamically generate these images and add the CBitmaps to the image list, if that helps. They are not icons in the Windows sense
I have a PNG file with 45x45 ratio
I have Qlabel with 270x30 Pixel ratio
what I want is to insert PNG file as background and Text on it dynamilaclly.
Text length may change from large to small and vise versa,
accorindly our image changes and fit the text inside the images its mean flexible image according to the text
QPixmap pixmapTarget = QPixmap(":/.png");
pixmapTarget = pixmapTarget.scaled(250, 27, Qt::IgnoreAspectRatio , Qt::SmoothTransformation);
ui->lable_1->setIcon(pixmapTarget);
but dont to insert text in the image and how to get flexible thing accoudning to the text.
A QLabel can contain either a text or an image. Not both at same time. If you want to have an image as a background to a text, you will need to either use a QTextView and setup your text and background image as rich text, overlay two QLabel instances on top of each other with the image being the bottom one, or implement your own custom QWidget. The latter can be done in a variety of ways, including subclassing QLabel to in paintEvent first render the background image (see QPainter's documentation on how to draw a QImage or better, a QPixmap) and then call the base implementation of paintEvent to render the text.
I'm using Qt 5.10.1. I created a window icon resource and applied to Qt application like following:
a.setWindowIcon(QIcon(":/icons/resources/logo_icon.png"));
The size of logo_icon.png is 256*256.
The result is this:
The icon is a little blurrly, which is not what I expected. For comparison, following is the window icon of GIMP in which I designed the icon:
I tried various sizes of the image from 16*16 to 256*256, there was no luck. Changing image format to ico from png also didn't work.
What should I do to render a clearer window icon?
Maybe in the ui file of your window there is a iconSize value that makes your icon scale not very well when rendered by the window manager. This blurry effect occurred to me sometimes because the size was 15 px instead of 16 (or another power of 2).
Try to open the .ui file of your main window in Design mode and look under the QMainWindow group in the widget properties panel to set the iconSize to something like 16.
You can also set the icon file from there, using the windowIcon property under the QWidget group.
I have a .ico file that I've imported into my Visual Studio 2010 project. Within the .ico file, it looks like there are many different images of different sizes.
I am trying to set one of them as the icon for my button control:
HICON hIcon = LoadIcon(HINST_THISCOMPONENT, MAKEINTRESOURCE(IDI_ICON2));
SendMessage(GetDlgItem(hDlg, IDC_BUTTON1), BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
How do I choose which image/size within the .ico file will be displayed on the button?
You can use the LoadImage function to get a bit more control.
With LoadImage you can specify a desired width and height.
If you want even more control then you're down to parsing the icon resource, which I don't recommend.
I want to create a toolbar with custom image buttons, I have the images in .ico format how can I add them to the toolar in WTL? I'm trying to edit the images in the toolbar list, but there such poor quality, how can I add better quality images?
If you have a WTL Toolbar control that is already created you can attach images to it with the SetImageList() and SetHotImageList() methods of the CToolBarCtrl class. E.g.
CToolBarCtrl toolbar;
CImage image;
CBitmap bitmap;
// ... load the image into the bitmap ...
images.Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 1);
// repeat this for each image you want to use in the toolabr
images.Add(bitmap, RGB(255, 255, 255));
toolbar.SetImageList(images.Detach());
//... do the same for the hot (hover) images ...
The images can then be used by referencing the return value of the CImageList:Add() method.
Make sure you detach the image list from the CImageList class as I have done here otherwise the image list will be deleted when it goes out of scope.