Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to use a png or jpg in visual studio?

How to use a png or jpg in visual studio?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpvisual-studiographicshelp
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DanYELL
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • D DanYELL

      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

      S Offline
      S Offline
      Santhosh G_
      wrote on last edited by
      #2

      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+[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups