Guest User

Untitled

a guest
Nov 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. struct raw_image
  2. {
  3. void* data;
  4. int size;
  5. };
  6.  
  7. ALIGNMENT_API void submit( raw_image& img )
  8. {
  9. cv::Mat mat = cv::imdecode( cv::_InputArray(
  10. static_cast<uchar*>( img.data ), img.size ), cv::IMREAD_COLOR );
  11. cv::imshow( "image", mat );
  12. cv::waitKey( );
  13. cv::destroyWindow( "image" );
  14. }
  15.  
  16. [StructLayout( LayoutKind.Sequential )]
  17. internal unsafe struct RawImage
  18. {
  19. internal void* ImageData;
  20. internal int Length;
  21. }
  22.  
  23. [DllImport( "alignment-vc141-mtd-x64.dll", CallingConvention =
  24. CallingConvention.Cdecl )]
  25. static extern void submit( RawImage img );
  26.  
  27. using( var bitmap = new Bitmap( "AlignmentCenter.jpg" ) )
  28. using( var stream = new MemoryStream( ) )
  29. {
  30. bitmap.Save( stream, ImageFormat.Jpeg );
  31. var source = stream.ToArray( );
  32. fixed( void* ptr = source )
  33. {
  34. var raw = new RawImage
  35. {
  36. ImageData = ptr,
  37. Length = source.Length
  38. };
  39. submit( raw );
  40. }
  41. }
Add Comment
Please, Sign In to add comment