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. @#$%(#($ Microsoft and GDI+

@#$%(#($ Microsoft and GDI+

Scheduled Pinned Locked Moved C#
graphicscsharpcsswinformsdata-structures
5 Posts 4 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.
  • C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #1

    I've been starting an image processing library in C#/GDI+ tonight and I've hit a couple of snags. One is asked about below, I can't see how to link two different files together, a la #include. The other is more vexing. GDI+ provides a Bitmap class, which has a LockBits method. Well and good, but it appears that in C# I must write 'unsafe' code in order to use it to access the bitmap data of the image. In fact, Eric Gunnerson, no less, has examples of this online, so I'm pretty sure if you want to use BitmapData, you need to write code that is not going to be able to run in the grand scheme of things, i.e. over the web. Does that strike anyone else as pathetic ? It's not an esotetic pointer, but in fact a well defined chunck of memory that I need simply to access in array like fashion. Why is that so hard ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

    J J E 3 Replies Last reply
    0
    • C Christian Graus

      I've been starting an image processing library in C#/GDI+ tonight and I've hit a couple of snags. One is asked about below, I can't see how to link two different files together, a la #include. The other is more vexing. GDI+ provides a Bitmap class, which has a LockBits method. Well and good, but it appears that in C# I must write 'unsafe' code in order to use it to access the bitmap data of the image. In fact, Eric Gunnerson, no less, has examples of this online, so I'm pretty sure if you want to use BitmapData, you need to write code that is not going to be able to run in the grand scheme of things, i.e. over the web. Does that strike anyone else as pathetic ? It's not an esotetic pointer, but in fact a well defined chunck of memory that I need simply to access in array like fashion. Why is that so hard ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

      J Offline
      J Offline
      Jason Hooper
      wrote on last edited by
      #2

      Christian Graus wrote: It's not an esotetic pointer Holy thank God... - Jason Do you have a Pulse? SonorkID: 100.611 Jason

      1 Reply Last reply
      0
      • C Christian Graus

        I've been starting an image processing library in C#/GDI+ tonight and I've hit a couple of snags. One is asked about below, I can't see how to link two different files together, a la #include. The other is more vexing. GDI+ provides a Bitmap class, which has a LockBits method. Well and good, but it appears that in C# I must write 'unsafe' code in order to use it to access the bitmap data of the image. In fact, Eric Gunnerson, no less, has examples of this online, so I'm pretty sure if you want to use BitmapData, you need to write code that is not going to be able to run in the grand scheme of things, i.e. over the web. Does that strike anyone else as pathetic ? It's not an esotetic pointer, but in fact a well defined chunck of memory that I need simply to access in array like fashion. Why is that so hard ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

        J Offline
        J Offline
        James T Johnson
        wrote on last edited by
        #3

        I think what you're seeing is a direct inclusion of GDI+. It would have been nice if it had an array accessor though :( James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

        1 Reply Last reply
        0
        • C Christian Graus

          I've been starting an image processing library in C#/GDI+ tonight and I've hit a couple of snags. One is asked about below, I can't see how to link two different files together, a la #include. The other is more vexing. GDI+ provides a Bitmap class, which has a LockBits method. Well and good, but it appears that in C# I must write 'unsafe' code in order to use it to access the bitmap data of the image. In fact, Eric Gunnerson, no less, has examples of this online, so I'm pretty sure if you want to use BitmapData, you need to write code that is not going to be able to run in the grand scheme of things, i.e. over the web. Does that strike anyone else as pathetic ? It's not an esotetic pointer, but in fact a well defined chunck of memory that I need simply to access in array like fashion. Why is that so hard ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

          E Offline
          E Offline
          Eric Gunnerson msft
          wrote on last edited by
          #4

          Well, you don't have to use LockData; you can use GetPixel() and SetPixel(), which has pretty poor performance, so it's probably not a valid solution. I've made the same comments to the GDI+ folks. Note that there's going to be more overhead with array-based access regardless of how they do it; not only do you have the array indexing, but you also have the conversion from the bitmap format to the independant format (ie Color).

          C 1 Reply Last reply
          0
          • E Eric Gunnerson msft

            Well, you don't have to use LockData; you can use GetPixel() and SetPixel(), which has pretty poor performance, so it's probably not a valid solution. I've made the same comments to the GDI+ folks. Note that there's going to be more overhead with array-based access regardless of how they do it; not only do you have the array indexing, but you also have the conversion from the bitmap format to the independant format (ie Color).

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Yes, while I imagine Get/SetPixl is not as slow as under GDI, there is at least the overhead of the function calls per pixel. I'd be happy if they just gave me the data in an array and left it up to me to keep track of where I was, and which was blue, green, red. While I'm on that, why does GDI+ have me specify 24BitRGB, but I get back 24BitBGR ? I know BGR is windows internal format, but why not make the flag that then ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

            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