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#
  4. Displaying an image generated in c++/CLI DLL

Displaying an image generated in c++/CLI DLL

Scheduled Pinned Locked Moved C#
csharpc++data-structureshelp
3 Posts 3 Posters 0 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.
  • E Offline
    E Offline
    eyalbi007
    wrote on last edited by
    #1

    Hi All, I have a routine that calls a C++/CLI DLL from C# in order to generate an image. After the generation, I have (in the DLL) a pointer to 'unsigned short' array and the image dimensions. Now I'd like to somehow use this pointer to display the image in a C# form (using PictureBox ot ony other suitable component), but I have no idea how... Thanks for the help, Eyal.

    B L 2 Replies Last reply
    0
    • E eyalbi007

      Hi All, I have a routine that calls a C++/CLI DLL from C# in order to generate an image. After the generation, I have (in the DLL) a pointer to 'unsigned short' array and the image dimensions. Now I'd like to somehow use this pointer to display the image in a C# form (using PictureBox ot ony other suitable component), but I have no idea how... Thanks for the help, Eyal.

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      Create a Bitmap of the right size with the appropriate pixel depth (not sure what that is for ushort, you might have to convert on the fly), call LockBits to get the address of its data, and copy the data from the C array into that one (using unsafe code or Marshal methods, depending on your requirements).

      1 Reply Last reply
      0
      • E eyalbi007

        Hi All, I have a routine that calls a C++/CLI DLL from C# in order to generate an image. After the generation, I have (in the DLL) a pointer to 'unsigned short' array and the image dimensions. Now I'd like to somehow use this pointer to display the image in a C# form (using PictureBox ot ony other suitable component), but I have no idea how... Thanks for the help, Eyal.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        you might be lucky and find the solution here[^]; make sure to read all of it though. :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum

        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