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