Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CommonUI / System / Drawing / Advanced / ImageCodecInfo.cs / 1 / ImageCodecInfo.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing.Imaging {
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System;
using System.Drawing;
using System.Drawing.Internal;
// sdkinc\imaging.h
///
///
/// [To be supplied.]
///
public sealed class ImageCodecInfo {
Guid clsid;
Guid formatID;
string codecName;
string dllName;
string formatDescription;
string filenameExtension;
string mimeType;
ImageCodecFlags flags;
int version;
byte[][] signaturePatterns;
byte[][] signatureMasks;
internal ImageCodecInfo() {
}
///
///
/// [To be supplied.]
///
public Guid Clsid {
get { return clsid; }
set { clsid = value; }
}
///
///
/// [To be supplied.]
///
public Guid FormatID {
get { return formatID; }
set { formatID = value; }
}
///
///
/// [To be supplied.]
///
public string CodecName {
get { return codecName; }
set { codecName = value; }
}
///
///
/// [To be supplied.]
///
public string DllName {
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
get {
if (dllName != null) {
//a valid path is a security concern, demand
//path discovery permission....
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, dllName).Demand();
}
return dllName;
}
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
set {
if (value != null) {
//a valid path is a security concern, demand
//path discovery permission....
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, value).Demand();
}
dllName = value;
}
}
///
///
/// [To be supplied.]
///
public string FormatDescription {
get { return formatDescription; }
set { formatDescription = value; }
}
///
///
/// [To be supplied.]
///
public string FilenameExtension {
get { return filenameExtension; }
set { filenameExtension = value; }
}
///
///
/// [To be supplied.]
///
public string MimeType {
get { return mimeType; }
set { mimeType = value; }
}
///
///
/// [To be supplied.]
///
public ImageCodecFlags Flags {
get { return flags; }
set { flags = value; }
}
///
///
/// [To be supplied.]
///
public int Version {
get { return version; }
set { version = value; }
}
///
///
/// [To be supplied.]
///
[CLSCompliant(false)]
public byte[][] SignaturePatterns {
get { return signaturePatterns; }
set { signaturePatterns = value; }
}
///
///
/// [To be supplied.]
///
[CLSCompliant(false)]
public byte[][] SignatureMasks {
get { return signatureMasks; }
set { signatureMasks = value; }
}
// Encoder/Decoder selection APIs
///
///
/// [To be supplied.]
///
public static ImageCodecInfo[] GetImageDecoders() {
ImageCodecInfo[] imageCodecs;
int numDecoders;
int size;
int status = SafeNativeMethods.Gdip.GdipGetImageDecodersSize(out numDecoders, out size);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
IntPtr memory = Marshal.AllocHGlobal(size);
try {
status = SafeNativeMethods.Gdip.GdipGetImageDecoders(numDecoders, size, memory);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
imageCodecs = ImageCodecInfo.ConvertFromMemory(memory, numDecoders);
}
finally {
Marshal.FreeHGlobal(memory);
}
return imageCodecs;
}
///
///
/// [To be supplied.]
///
public static ImageCodecInfo[] GetImageEncoders() {
ImageCodecInfo[] imageCodecs;
int numEncoders;
int size;
int status = SafeNativeMethods.Gdip.GdipGetImageEncodersSize(out numEncoders, out size);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
IntPtr memory = Marshal.AllocHGlobal(size);
try {
status = SafeNativeMethods.Gdip.GdipGetImageEncoders(numEncoders, size, memory);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
imageCodecs = ImageCodecInfo.ConvertFromMemory(memory, numEncoders);
}
finally {
Marshal.FreeHGlobal(memory);
}
return imageCodecs;
}
/* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future.
internal static ImageCodecInfoPrivate ConvertToMemory(ImageCodecInfo imagecs)
{
ImageCodecInfoPrivate imagecsp = new ImageCodecInfoPrivate();
imagecsp.Clsid = imagecs.Clsid;
imagecsp.FormatID = imagecs.FormatID;
imagecsp.CodecName = Marshal.StringToHGlobalUni(imagecs.CodecName);
imagecsp.DllName = Marshal.StringToHGlobalUni(imagecs.DllName);
imagecsp.FormatDescription = Marshal.StringToHGlobalUni(imagecs.FormatDescription);
imagecsp.FilenameExtension = Marshal.StringToHGlobalUni(imagecs.FilenameExtension);
imagecsp.MimeType = Marshal.StringToHGlobalUni(imagecs.MimeType);
imagecsp.Flags = (int)imagecs.Flags;
imagecsp.Version = (int)imagecs.Version;
imagecsp.SigCount = imagecs.SignaturePatterns.Length;
imagecsp.SigSize = imagecs.SignaturePatterns[0].Length;
imagecsp.SigPattern = Marshal.AllocHGlobal(imagecsp.SigCount*imagecsp.SigSize);
imagecsp.SigMask = Marshal.AllocHGlobal(imagecsp.SigCount*imagecsp.SigSize);
for (int i=0; i
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing.Imaging {
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System;
using System.Drawing;
using System.Drawing.Internal;
// sdkinc\imaging.h
///
///
/// [To be supplied.]
///
public sealed class ImageCodecInfo {
Guid clsid;
Guid formatID;
string codecName;
string dllName;
string formatDescription;
string filenameExtension;
string mimeType;
ImageCodecFlags flags;
int version;
byte[][] signaturePatterns;
byte[][] signatureMasks;
internal ImageCodecInfo() {
}
///
///
/// [To be supplied.]
///
public Guid Clsid {
get { return clsid; }
set { clsid = value; }
}
///
///
/// [To be supplied.]
///
public Guid FormatID {
get { return formatID; }
set { formatID = value; }
}
///
///
/// [To be supplied.]
///
public string CodecName {
get { return codecName; }
set { codecName = value; }
}
///
///
/// [To be supplied.]
///
public string DllName {
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
get {
if (dllName != null) {
//a valid path is a security concern, demand
//path discovery permission....
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, dllName).Demand();
}
return dllName;
}
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
set {
if (value != null) {
//a valid path is a security concern, demand
//path discovery permission....
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, value).Demand();
}
dllName = value;
}
}
///
///
/// [To be supplied.]
///
public string FormatDescription {
get { return formatDescription; }
set { formatDescription = value; }
}
///
///
/// [To be supplied.]
///
public string FilenameExtension {
get { return filenameExtension; }
set { filenameExtension = value; }
}
///
///
/// [To be supplied.]
///
public string MimeType {
get { return mimeType; }
set { mimeType = value; }
}
///
///
/// [To be supplied.]
///
public ImageCodecFlags Flags {
get { return flags; }
set { flags = value; }
}
///
///
/// [To be supplied.]
///
public int Version {
get { return version; }
set { version = value; }
}
///
///
/// [To be supplied.]
///
[CLSCompliant(false)]
public byte[][] SignaturePatterns {
get { return signaturePatterns; }
set { signaturePatterns = value; }
}
///
///
/// [To be supplied.]
///
[CLSCompliant(false)]
public byte[][] SignatureMasks {
get { return signatureMasks; }
set { signatureMasks = value; }
}
// Encoder/Decoder selection APIs
///
///
/// [To be supplied.]
///
public static ImageCodecInfo[] GetImageDecoders() {
ImageCodecInfo[] imageCodecs;
int numDecoders;
int size;
int status = SafeNativeMethods.Gdip.GdipGetImageDecodersSize(out numDecoders, out size);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
IntPtr memory = Marshal.AllocHGlobal(size);
try {
status = SafeNativeMethods.Gdip.GdipGetImageDecoders(numDecoders, size, memory);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
imageCodecs = ImageCodecInfo.ConvertFromMemory(memory, numDecoders);
}
finally {
Marshal.FreeHGlobal(memory);
}
return imageCodecs;
}
///
///
/// [To be supplied.]
///
public static ImageCodecInfo[] GetImageEncoders() {
ImageCodecInfo[] imageCodecs;
int numEncoders;
int size;
int status = SafeNativeMethods.Gdip.GdipGetImageEncodersSize(out numEncoders, out size);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
IntPtr memory = Marshal.AllocHGlobal(size);
try {
status = SafeNativeMethods.Gdip.GdipGetImageEncoders(numEncoders, size, memory);
if (status != SafeNativeMethods.Gdip.Ok) {
throw SafeNativeMethods.Gdip.StatusException(status);
}
imageCodecs = ImageCodecInfo.ConvertFromMemory(memory, numEncoders);
}
finally {
Marshal.FreeHGlobal(memory);
}
return imageCodecs;
}
/* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future.
internal static ImageCodecInfoPrivate ConvertToMemory(ImageCodecInfo imagecs)
{
ImageCodecInfoPrivate imagecsp = new ImageCodecInfoPrivate();
imagecsp.Clsid = imagecs.Clsid;
imagecsp.FormatID = imagecs.FormatID;
imagecsp.CodecName = Marshal.StringToHGlobalUni(imagecs.CodecName);
imagecsp.DllName = Marshal.StringToHGlobalUni(imagecs.DllName);
imagecsp.FormatDescription = Marshal.StringToHGlobalUni(imagecs.FormatDescription);
imagecsp.FilenameExtension = Marshal.StringToHGlobalUni(imagecs.FilenameExtension);
imagecsp.MimeType = Marshal.StringToHGlobalUni(imagecs.MimeType);
imagecsp.Flags = (int)imagecs.Flags;
imagecsp.Version = (int)imagecs.Version;
imagecsp.SigCount = imagecs.SignaturePatterns.Length;
imagecsp.SigSize = imagecs.SignaturePatterns[0].Length;
imagecsp.SigPattern = Marshal.AllocHGlobal(imagecsp.SigCount*imagecsp.SigSize);
imagecsp.SigMask = Marshal.AllocHGlobal(imagecsp.SigCount*imagecsp.SigSize);
for (int i=0; i
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataSourceExpressionCollection.cs
- DataGridViewBand.cs
- PointIndependentAnimationStorage.cs
- TypeBinaryExpression.cs
- RangeBase.cs
- FilteredDataSetHelper.cs
- AssemblyCollection.cs
- ZipIOExtraFieldZip64Element.cs
- SystemIcons.cs
- CallTemplateAction.cs
- SystemInfo.cs
- ExpressionBuilderContext.cs
- X509IssuerSerialKeyIdentifierClause.cs
- BulletChrome.cs
- XmlEventCache.cs
- Int32Animation.cs
- AuthenticationServiceManager.cs
- RegexGroup.cs
- IPEndPoint.cs
- InternalSendMessage.cs
- RtfToken.cs
- WebPartDesigner.cs
- BamlReader.cs
- BitmapImage.cs
- TreeView.cs
- _MultipleConnectAsync.cs
- MemoryRecordBuffer.cs
- RelOps.cs
- RowUpdatingEventArgs.cs
- PolicyException.cs
- SizeAnimationUsingKeyFrames.cs
- UIElement3D.cs
- ConfigXmlDocument.cs
- Walker.cs
- EventSinkHelperWriter.cs
- EmptyEnumerator.cs
- PropertyCollection.cs
- control.ime.cs
- BufferBuilder.cs
- SrgsItemList.cs
- DatePickerAutomationPeer.cs
- SoapIgnoreAttribute.cs
- ContentElement.cs
- CommandBindingCollection.cs
- Helpers.cs
- _ListenerResponseStream.cs
- BlockUIContainer.cs
- XmlSchemaObject.cs
- DesignerForm.cs
- XmlMemberMapping.cs
- ChangeInterceptorAttribute.cs
- MD5CryptoServiceProvider.cs
- RouteParameter.cs
- ITextView.cs
- ICspAsymmetricAlgorithm.cs
- VisualTreeHelper.cs
- DocumentAutomationPeer.cs
- AppDomainFactory.cs
- MergablePropertyAttribute.cs
- ProtectedConfigurationProviderCollection.cs
- CompareValidator.cs
- EpmTargetTree.cs
- PersonalizationProvider.cs
- DomainUpDown.cs
- DescendantQuery.cs
- WebPageTraceListener.cs
- DefaultPrintController.cs
- xsdvalidator.cs
- ExchangeUtilities.cs
- XmlElement.cs
- LookupNode.cs
- DBSqlParserColumnCollection.cs
- RoleManagerEventArgs.cs
- FaultBookmark.cs
- DateTimeFormatInfoScanner.cs
- XmlDigitalSignatureProcessor.cs
- XsdBuilder.cs
- CompressedStack.cs
- LinkLabelLinkClickedEvent.cs
- XsltContext.cs
- ConnectionConsumerAttribute.cs
- MemoryRecordBuffer.cs
- SecurityTokenRequirement.cs
- FileSystemWatcher.cs
- MemberPathMap.cs
- MouseDevice.cs
- EndpointNotFoundException.cs
- Char.cs
- FormsAuthenticationTicket.cs
- ToolStripItemEventArgs.cs
- RadioButton.cs
- MenuItem.cs
- ExceptionHandlers.cs
- PackageStore.cs
- EllipticalNodeOperations.cs
- SqlUDTStorage.cs
- IImplicitResourceProvider.cs
- ErasingStroke.cs
- ChildDocumentBlock.cs
- CompilerParameters.cs