JpegBitmapDecoder Class
Defines a decoder for Joint Photographics Experts Group (JPEG) encoded images.
System.Windows.Threading::DispatcherObject
System.Windows.Media.Imaging::BitmapDecoder
System.Windows.Media.Imaging::JpegBitmapDecoder
Assembly: PresentationCore (in PresentationCore.dll)
The JpegBitmapDecoder type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | JpegBitmapDecoder(Stream, BitmapCreateOptions, BitmapCacheOption) | Initializes a new instance of the JpegBitmapDecoder class from the specified file stream, with the specified createOptions and cacheOption. |
![]() | JpegBitmapDecoder(Uri, BitmapCreateOptions, BitmapCacheOption) | Initializes a new instance of the JpegBitmapDecoder class from the specified Uri, with the specified createOptions and cacheOption. |
| Name | Description | |
|---|---|---|
![]() | CodecInfo | Gets information that describes this codec. (Inherited from BitmapDecoder.) |
![]() | ColorContexts | Gets a value that represents the color profile associated with a bitmap, if one is defined. (Inherited from BitmapDecoder.) |
![]() | Dispatcher | Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.) |
![]() | Frames | Gets the content of an individual frame within a bitmap. (Inherited from BitmapDecoder.) |
![]() | IsDownloading | Gets a value that indicates if the decoder is currently downloading content. (Inherited from BitmapDecoder.) |
![]() | Metadata | Gets an instance of BitmapMetadata that represents the global metadata associated with this bitmap, if metadata is defined. (Inherited from BitmapDecoder.) |
![]() | Palette | Gets the BitmapPalette associated with this decoder. (Inherited from BitmapDecoder.) |
![]() | Preview | Gets a BitmapSource that represents the global preview of this bitmap, if one is defined. (Inherited from BitmapDecoder.) |
![]() | Thumbnail | Gets a BitmapSource that represents the thumbnail of the bitmap, if one is defined. (Inherited from BitmapDecoder.) |
| Name | Description | |
|---|---|---|
![]() | CheckAccess | Determines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.) |
![]() | CreateInPlaceBitmapMetadataWriter | Creates an instance of InPlaceBitmapMetadataWriter, which can be used to update the metadata of a bitmap. (Inherited from BitmapDecoder.) |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Frees resources and performs other cleanup operations before the BitmapDecoder is reclaimed by garbage collection. (Inherited from BitmapDecoder.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Converts the current value of a BitmapDecoder to a String. (Inherited from BitmapDecoder.) |
![]() | VerifyAccess | Enforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.) |
| Name | Description | |
|---|---|---|
![]() | DownloadCompleted | Occurs when a BitmapDecoder has finished downloading bitmap content. (Inherited from BitmapDecoder.) |
![]() | DownloadFailed | Occurs when bitmap content failed to download. (Inherited from BitmapDecoder.) |
![]() | DownloadProgress | Occurs when a BitmapDecoder has made progress downloading bitmap content. (Inherited from BitmapDecoder.) |
The following table list the PixelFormats that are supported by the JpegBitmapDecoder class.
The following examples show how to decode and encode a JPEG image using the specific JpegBitmapDecoder and JpegBitmapEncoder objects.
This example demonstrates how to decode a JPEG image using a JpegBitmapDecoder from a FileStream.
// Open a Stream and decode a JPEG image Stream^ imageStreamSource = gcnew FileStream("tulipfarm.jpg", FileMode::Open, FileAccess::Read, FileShare::Read); JpegBitmapDecoder^ decoder = gcnew JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default); BitmapSource^ bitmapSource = decoder->Frames[0]; // Draw the Image Image^ myImage = gcnew Image(); myImage->Source = bitmapSource; myImage->Stretch = Stretch::None; myImage->Margin = System::Windows::Thickness(20);
This example demonstrates how to encode a BitmapSource into a JPEG image using a JpegBitmapEncoder.
int width = 128; int height = width; int stride = width / 8; array<System::Byte>^ pixels = gcnew array<System::Byte>(height * stride); // Define the image palette BitmapPalette^ myPalette = BitmapPalettes::Halftone256; // Creates a new empty image with the pre-defined palette. BitmapSource^ image = BitmapSource::Create( width, height, 96, 96, PixelFormats::Indexed1, myPalette, pixels, stride); System::IO::FileStream^ stream = gcnew System::IO::FileStream("new.jpg", FileMode::Create); JpegBitmapEncoder^ encoder = gcnew JpegBitmapEncoder(); TextBlock^ myTextBlock = gcnew System::Windows::Controls::TextBlock(); myTextBlock->Text = "Codec Author is: " + encoder->CodecInfo->Author->ToString(); encoder->FlipHorizontal = true; encoder->FlipVertical = false; encoder->QualityLevel = 30; encoder->Rotation = Rotation::Rotate90; encoder->Frames->Add(BitmapFrame::Create(image)); encoder->Save(stream);
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
