Original Post
Hey Guys, if someone can help me, I'll be thankful. Well, I have a program which transfer the bitmap (DIB Section) from a MFC's CImage object to an array of integers, which is my pixels array. Here's the code: for (unsigned int y = 0; y < height; y++) { int line = y * width; for (unsigned int x = 0; x < width; x++) { // Extract color information for pixel and build an equivalent Java pixel // for storage in the Java-based integer array. // The CImage::GetPixel return an pixel in the following format: 0xAARRGGBB // But java.awt.Image needs a image in the follow format: 0xAABBGGRR // Where: // A = alpha, R=red, G=green, B=blue, // And the 'or' operator (|) is used to make the image opaque: A=0xFF // This code is very inefficient, try other approaches COLORREF pixel = (COLORREF)cImage.GetPixel(x,y); pixel = 0xff000000 | RGB(GetBValue(pixel), GetGValue(pixel), GetRValue(pixel)); // Store the pixel in the array at the appropriate index. pixelsArray[line + x] = (jint) pixel; } } As you can see, I get pixel by pixel the image from CImage object and put it in my pixel array. This code is extremelly slow and is consuming too much time and processing of my application. Here's the deal, I need performance in this specific code! First of all, my objective was make that code work, now I need to improve that! The most important thing is that I have to make a swith from RGB to BGR pixel format, because the object which will receive the filled array interpret the bytes/pixels in that format. Thanks