Advertisement
goofer

Untitled

Jan 31st, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. //I get image from simple resources (not an embedded)
  2.  
  3. //At first I've created converter from a Bitmap to BitmapImage
  4. public static class BitmapSourceConverter
  5. {
  6. public static BitmapSource ConvertFromImage(Bitmap image)
  7. {
  8. return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
  9. image.GetHbitmap(),
  10. IntPtr.Zero,
  11. System.Windows.Int32Rect.Empty,
  12. BitmapSizeOptions.FromEmptyOptions());
  13. }
  14. }
  15.  
  16. //And usage
  17. pushButton.LargeImage = BitmapSourceConverter.ConvertFromImage(Resources.buttonImage);
  18. //where buttonImage is the image assembly resource which you can add via assembly properties.
  19.  
  20. //Here is highlighted code: http://pastebin.com/ZcQYN78v
  21.  
  22. //I think this code is more obvious and more simple than yours because there is no need to use assembly.
  23.  
  24. //Hope this information is useful.
  25.  
  26. //Best regards, Victor.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement