Copy memory buffer to BitmapData
I am trying to copy the unpacked image to a BitmapData object using copy_mem_image(), however it gives an error saying Access Violation. Where is the problem? My code is as follows:
int check = Processor1->dcraw_process(); libraw_processed_image_t *image = Processor1->dcraw_make_mem_image(&check); int step; step = image->width*(24/8)*3; //create a bitmap with the image size Bitmap^ pic = gcnew Bitmap(image->width, image->height); System::Drawing::Rectangle rect = System::Drawing::Rectangle(0,0,image->width,image->height); BitmapData^ bmpData = pic->LockBits( rect, ImageLockMode::ReadWrite, PixelFormat::Format24bppRgb ); // Get the address of the first line. IntPtr bmpPtr = bmpData->Scan0; Processor1->copy_mem_image(&bmpPtr, step, 0); // Unlock the bits. pic->UnlockBits( bmpData );
Recent comments