Questions tagged [bitmapsource]

Bitmapsource represents a single, constant set of pixels at a certain size and resolution.

What questions should have this tag:
.Net Framework questions utilizing the BitmapSource class under the System.Windows.Media.Imaging namespace.

Basic Definitions:
Maximum height and width of an image: 2^16 pixels at 32 bits per channel * 4 channels
Maximum size of a BitmapSource: 2^32 bytes (64 gigabytes)
Maximum image size: 4 (four) gigapixels
Minimum image size: 1x1

Brief Introduction:
Part of the Windows Presentation Foundation (WPF) imaging pipeline, BitmapSource represents a single, constant set of pixels at a certain size and resolution. Multi-frame images and animations are not represented by BitmapSource.

Important Links:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx

136 questions
6
votes
1 answer

How to read pixels in four corners of a BitmapSource?

I have a .NET BitmapSource object. I would like to read the four pixels in corners of the bitmap, and test whether all of them are darker than white. How can I do that? Edit: I wouldn't mind converting this object to another type with a better API.
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
5
votes
2 answers

Convert BitmapSource to MemoryStream

How Do I convert BitmapSource to MemoryStream. Though I tried some code: private Stream StreamFromBitmapSource(BitmapSource writeBmp) { Stream bmp; using (bmp = new MemoryStream()) { BitmapEncoder enc = new…
Aarti Dhiman
  • 75
  • 1
  • 9
5
votes
2 answers

Why this Bitmap Image changes its size after I load it?

Quick question: I have this 1000 x 1000 bitmap image: and I use this routine to load it: private BitmapSource initialBitmap = new BitmapImage(new Uri("C:\\Users\\...\\Desktop\\Original.bmp")); Why after I load it, and right after I step over the…
Khalil Khalaf
  • 9,259
  • 11
  • 62
  • 104
5
votes
4 answers

How to copy DispatcherObject (BitmapSource) into different thread?

I am trying to figure out how can I copy DispatcherObject (in my case BitmapSource) into another thread. Use case: I have a WPF app that needs to show window in a new thread (the app is actually Outlook addin and we need to do this because Outlook…
Tomáš Kafka
  • 4,405
  • 6
  • 39
  • 52
5
votes
3 answers

InteropBitmap to BitmapImage

I'm trying to Convert a Bitmap (SystemIcons.Question) to a BitmapImage so I can use it in a WPF Image control. I have the following method to convert it to a BitmapSource, but it returns an InteropBitmapImage, now the problem is how to convert it to…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
5
votes
2 answers

WPF/BackgroundWorker and BitmapSource problem

I am a beginner with WPF and trying a home project to become familiar with the technology. I have a simple form where the user selects an image file, I then display EXIF data along with a thumbnail of the image. This is working fine but when I…
Fermin
  • 34,961
  • 21
  • 83
  • 129
4
votes
1 answer

BitmapSource.CopyPixels->byte[]->BitmapSource how to do this simple?

How to do efficient BitmapSource to byte[] and vice versa conversion in C#?
curiousity
  • 4,703
  • 8
  • 39
  • 59
4
votes
0 answers

Downloading image through bitmapsource block rest of API calls

I have strange problem with my API calls. I'm writing WPF application with usage of RestSharp. All my calls to API uses RestSharp. I have a Photos module, which downloads only urls of photos. From that URLs I'm creating BitmapSource objects. I have…
Tomasz
  • 2,051
  • 3
  • 31
  • 64
4
votes
1 answer

Saving 8-bit indexed data in a PNG alters original bytes when using BitmapSource, PngBitmapEncoder/Decoder

I have a problem when saving and loading a PNG using BitmapSource and PngBitmapEncoder/Decoder. Basically, I'd like to be able to save an image that originated as an array of bytes, and when the PNG is loaded into my program, reload the exact same…
3
votes
3 answers

When binding an image source to a BitmapSource, the image stays blank

I'm trying to show a camera feed from a Kinect in a WPF application. However, the image appears blank. Below is a snippet of what I have in my Kinect class, this all fires correctly, and the BitmapSource appears to be created fine. public delegate…
benjgorman
  • 702
  • 10
  • 31
3
votes
1 answer

Initializing BitmapSource with array of pixels

I am trying to marshal a native image data structure to BitmapSource. Here's the native struct: struct Bitmap_8Bit { public: unsigned char* data; int stride; int rows; int cols; …
Dina
  • 1,346
  • 1
  • 15
  • 35
3
votes
2 answers

Convert WPF Control to BitmapSource

This is kind of a two part question- First, why doesn't this code work? Canvas canvas = new Canvas { Width = 640, Height = 480 }; System.Windows.Size size = new System.Windows.Size( canvas.Width, canvas.Height); //Measure and arrange the…
Nicros
  • 5,031
  • 12
  • 57
  • 101
3
votes
1 answer

How to get the image format from Clipboard class?

I'm making a image viewer in C#. that feature is copy and paste function using Clipboard class on C#. And I succeeded to get image of BitmapSource. but it can not check image formats (jpeg, png, bmp). This is supported source from C# BitmapSource…
Jayden
  • 55
  • 1
  • 2
  • 7
3
votes
1 answer

Is it possible to modify a WPF BitmapSource in memory 'unsafe'ly from another thread

I would like to do some processing of images in a WPF application. However, I would like to modify the pixels of a BitmapSource in memory at runtime. I'm currently managing to do this using 'unsafe' code against an old fashioned…
ConfusedNoob
  • 9,826
  • 14
  • 64
  • 85
3
votes
1 answer

WPF Image won't display BitmapSource

I'm new to using WPF and GDI, and I'm having trouble displaying an image. My eventual goal is to build something expose-like. So far, I gray-out the screens, gather all the active HWNDs, and capture the screens of all the windows. For now, I have a…
directedition
  • 11,145
  • 18
  • 58
  • 79
1
2
3
9 10