The problem is that at the moment I am displaying the image on the form calling the SetPixel method for each pixel:
Code: Select all
Bitmap bmp(VIDEO_WIDTH, VIDEO_HEIGHT, Imaging::PixelFormat::Format32bppRgb);
for(int x=0; x<VIDEO_WIDTH; x++)
for(int y=0; y<VIDEO_HEIGHT; y++)
{
int a, r, g, b;
b=context->pixels[(y*VIDEO_WIDTH+x)*4+0];
g=context->pixels[(y*VIDEO_WIDTH+x)*4+1];
r=context->pixels[(y*VIDEO_WIDTH+x)*4+2];
a=context->pixels[(y*VIDEO_WIDTH+x)*4+3];
bmp.SetPixel(x, y, System::Drawing::Color::FromArgb(a, r, g, b));
}
this->pictureBox1->Image=bmp.GetThumbnailImage(VIDEO_WIDTH, VIDEO_HEIGHT, nullptr, System::IntPtr::Zero);
System::Drawing::Graphics ^g = System::Drawing::Graphics::FromImage(this->pictureBox1->Image);
g->DrawImage(bmp.GetThumbnailImage(VIDEO_WIDTH, VIDEO_HEIGHT, nullptr, System::IntPtr::Zero), 0, 0);
System::Drawing::Pen ^p = gcnew System::Drawing::Pen(System::Drawing::Color::Green, 4);
g->DrawLine . . . bla bla bla
I'd like to find a way to access the Image directly... someone told me to use GCHandle to pin the pixel of the Image, but I don't know what to do!
I have also found this link which seems quite useful http://www.bobpowell.net/lockingbits.htm
It would be great to do something like BitmapData->Scan0 = context->pixels so that there is no overhead for rearranging the pixel values.
Yet I don't know if this is possible.
There is also another problem, I've looked for documentation for vmem-chroma but I found nothing... Anyway RV32 gives me BGRA data, but .NET Image data is arranged in ARGB, is there a way to tell vmem to arrange the data as I want so that I can save the time or the rearrangement? I think it is the main cause of slowness and my project should work realtime.