Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct raw_image
- {
- void* data;
- int size;
- };
- ALIGNMENT_API void submit( raw_image& img )
- {
- cv::Mat mat = cv::imdecode( cv::_InputArray(
- static_cast<uchar*>( img.data ), img.size ), cv::IMREAD_COLOR );
- cv::imshow( "image", mat );
- cv::waitKey( );
- cv::destroyWindow( "image" );
- }
- [StructLayout( LayoutKind.Sequential )]
- internal unsafe struct RawImage
- {
- internal void* ImageData;
- internal int Length;
- }
- [DllImport( "alignment-vc141-mtd-x64.dll", CallingConvention =
- CallingConvention.Cdecl )]
- static extern void submit( RawImage img );
- using( var bitmap = new Bitmap( "AlignmentCenter.jpg" ) )
- using( var stream = new MemoryStream( ) )
- {
- bitmap.Save( stream, ImageFormat.Jpeg );
- var source = stream.ToArray( );
- fixed( void* ptr = source )
- {
- var raw = new RawImage
- {
- ImageData = ptr,
- Length = source.Length
- };
- submit( raw );
- }
- }
Add Comment
Please, Sign In to add comment