Windows form application c++, faster setPixel operation from 2D Buffer to managed Bitmap object

47 views Asked by At

I drew an image from 2 D buffer with height = 768 and width = 1024. After that step I will display a video (25 Hz) and so I try to get faster code for displaying image. The biggest problem is creating Bitmap with Bitmap->setPixel operation. How can I solve this speed problem?

Actually these two 'for' loops is slow down the code a lot. I need to copy unsigned char array buffer to Managed System::Bitmap. This is my problem. Probably, some marshal operation what I need but I cant find any solution

Bitmap^ newBM = gcnew Bitmap(Witdh,Height);
Color newColor;
for(int i = 0; i < Height; i++){ 
   for(int k = 0; k < Witdh; k++){
      newBM->->SetPixel(k,i,newColor.FromArgb(255 - ImageVal[i][k],0,0,0));   }}
0

There are 0 answers