0

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));   }}
  • What do you mean by "speed problem"? – Nico Haase Jun 22 '20 at 08:28
  • Speed Problem mean "I can repeating display image operation at 2,5 Hz and I need more like as 25 Hz. I will use this to display video. This part of my code is working so slow to get 25 Hz . " – Abdurrahman Jun 22 '20 at 10:15
  • Please add all such clarification to your question by editing it – Nico Haase Jun 22 '20 at 10:18
  • Sorry about clarification , 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 – Abdurrahman Jun 22 '20 at 10:19
  • The problem is that `SetPixel` method is extremely slow. Use [this](https://stackoverflow.com/questions/1563038/fast-work-with-bitmaps-in-c-sharp) approach instead. It's C# code but is easy to translate to C++\CLI. – Slawomir Orlowski Jun 23 '20 at 11:48

0 Answers0