How to use a png or jpg in visual studio?
-
I have an image of a form. I can easily add that image as a bitmap resource. Then in my CFormView, I click on Toolbox and Picture Control and I select Bitmap as the type and find the image from the list of images. I can then lay edit boxes on top of the form. The problem is, the form is just a black and white form and the bitmap takes up alot of space. I have several form images to add and my program is becoming really big in size. In contrast, a png or jpeg is alot smaller in size and the final software will be smaller. I can add a PNG as a resource. However, I click on Toolbox and add a Picture Control and then right click on that Picture Control to go to its properties and if I select Bitmap, it doesnt show the PNG as a image to select. How can I use the PNG that is added? Another question which is not crucial. How can I add a JPG as a resource? And if I add it, how can I then use it? If you can show me how to use a PNG or JPG or anything similar (not a GIF) and how to make it display, that would be great. Sincerely, Danielle Brina
-
I have an image of a form. I can easily add that image as a bitmap resource. Then in my CFormView, I click on Toolbox and Picture Control and I select Bitmap as the type and find the image from the list of images. I can then lay edit boxes on top of the form. The problem is, the form is just a black and white form and the bitmap takes up alot of space. I have several form images to add and my program is becoming really big in size. In contrast, a png or jpeg is alot smaller in size and the final software will be smaller. I can add a PNG as a resource. However, I click on Toolbox and add a Picture Control and then right click on that Picture Control to go to its properties and if I select Bitmap, it doesnt show the PNG as a image to select. How can I use the PNG that is added? Another question which is not crucial. How can I add a JPG as a resource? And if I add it, how can I then use it? If you can show me how to use a PNG or JPG or anything similar (not a GIF) and how to make it display, that would be great. Sincerely, Danielle Brina
If you can use GdiPlus library, Gdiplus::Bitmap can be used to load png and jpeg images. You need to copy RGB data from jpg or png file to your picture control. Please Note: GDI+ initialisation is required at startup of the application.
// Initialization of GDI+ library. // GDI+ is used for loading images of different file format. Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup(&m\_gdiplusToken, &gdiplusStartupInput, NULL);
Gdiplus::Bitmap::FromStream() can be uised to create Bitmap from resource data. Loading JPG & PNG resources using GDI+[^]