Bitmap-Stride a multiple of 4? [modified]
-
Hi there, In my project I'm creating a Bitmap from a char-ptr (as Scan0 IntPtr). Now the bitmap (->the char ptr) gets a changed size as a single region of the image ist cut out. If the stride is not a multiple of four, the createbitmap function causes an exception! Now what can I do? I have no possiblity to change the incoming char-ptr (because I get it sent on my interface). If I calculate the next %4 stride value and use it, my bitmap isn't displayed correctly. BTW: It's a monochrome image with a manually assigned MonoPalette, 1 BytePerPixel: Format8bppIndexed Thanks for always helping me so much! Special thanks to NAVANEETH!:rose: ************************************************ A little side question: From time to time my windows forms application is hanging in a strange way. I make a snapshot of a bitmap and display it in one of the two picture boxes. Now when I drag my mouse down on the forms, i. e. to maximize/minimize the form, there is no reaction and the application "hangs". My app is not run as an exe, it's loaded as a DLL from a superior application. It also occurs, that I am in the "main app" to calculate the image, then call the forms DLL to display it, but I do not get the "forms application" (although it is loaded) popped up from the task bar. Usually I have to click on the "forms app" in the taskbar -> then send an image from the main app -> and then the forms project gets popped up (you see, by aiming to popping it up before). But that is crap and shouldn't behave that way!
modified on Friday, September 11, 2009 8:39 AM
-
Hi there, In my project I'm creating a Bitmap from a char-ptr (as Scan0 IntPtr). Now the bitmap (->the char ptr) gets a changed size as a single region of the image ist cut out. If the stride is not a multiple of four, the createbitmap function causes an exception! Now what can I do? I have no possiblity to change the incoming char-ptr (because I get it sent on my interface). If I calculate the next %4 stride value and use it, my bitmap isn't displayed correctly. BTW: It's a monochrome image with a manually assigned MonoPalette, 1 BytePerPixel: Format8bppIndexed Thanks for always helping me so much! Special thanks to NAVANEETH!:rose: ************************************************ A little side question: From time to time my windows forms application is hanging in a strange way. I make a snapshot of a bitmap and display it in one of the two picture boxes. Now when I drag my mouse down on the forms, i. e. to maximize/minimize the form, there is no reaction and the application "hangs". My app is not run as an exe, it's loaded as a DLL from a superior application. It also occurs, that I am in the "main app" to calculate the image, then call the forms DLL to display it, but I do not get the "forms application" (although it is loaded) popped up from the task bar. Usually I have to click on the "forms app" in the taskbar -> then send an image from the main app -> and then the forms project gets popped up (you see, by aiming to popping it up before). But that is crap and shouldn't behave that way!
modified on Friday, September 11, 2009 8:39 AM
cherrymotion wrote:
I have no possiblity to change the incoming char-ptr (because I get it sent on my interface).
Then you need to copy the pixel data to a properly row-aligned array. You could use the Bitmap(Int32, Int32, PixelFormat) constructor and copy the incoming data row-by-row to the new bitmap's data.
Mark Salsbery Microsoft MVP - Visual C++ :java: