Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Advanced / ImageAttributes.cs / 1305376 / ImageAttributes.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing.Imaging { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.Drawing; using System.ComponentModel; using Microsoft.Win32; using System.Drawing.Drawing2D; using System.Drawing.Internal; using System.Globalization; using System.Runtime.Versioning; // sdkinc\GDIplusImageAttributes.h // There are 5 possible sets of color adjustments: // ColorAdjustDefault, // ColorAdjustBitmap, // ColorAdjustBrush, // ColorAdjustPen, // ColorAdjustText, // Bitmaps, Brushes, Pens, and Text will all use any color adjustments // that have been set into the default ImageAttributes until their own // color adjustments have been set. So as soon as any "Set" method is // called for Bitmaps, Brushes, Pens, or Text, then they start from // scratch with only the color adjustments that have been set for them. // Calling Reset removes any individual color adjustments for a type // and makes it revert back to using all the default color adjustments // (if any). The SetToIdentity method is a way to force a type to // have no color adjustments at all, regardless of what previous adjustments // have been set for the defaults or for that type. ////// /// Contains information about how image colors /// are manipulated during rendering. /// [StructLayout(LayoutKind.Sequential)] public sealed class ImageAttributes : ICloneable, IDisposable { #if FINALIZATION_WATCH private string allocationSite = Graphics.GetAllocationStack(); #endif /* * Handle to native image attributes object */ internal IntPtr nativeImageAttributes; internal void SetNativeImageAttributes(IntPtr handle) { if (handle == IntPtr.Zero) throw new ArgumentNullException("handle"); nativeImageAttributes = handle; } ////// /// Initializes a new instance of the [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public ImageAttributes() { IntPtr newImageAttributes = IntPtr.Zero; int status = SafeNativeMethods.Gdip.GdipCreateImageAttributes(out newImageAttributes); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); SetNativeImageAttributes(newImageAttributes); } internal ImageAttributes(IntPtr newNativeImageAttributes) { SetNativeImageAttributes(newNativeImageAttributes); } ///class. /// /// /// Cleans up Windows resources for this /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } void Dispose(bool disposing) { #if FINALIZATION_WATCH if (!disposing && nativeImageAttributes != IntPtr.Zero) Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite); #endif if (nativeImageAttributes != IntPtr.Zero) { try{ #if DEBUG int status = #endif SafeNativeMethods.Gdip.GdipDisposeImageAttributes(new HandleRef(this, nativeImageAttributes)); #if DEBUG Debug.Assert(status == SafeNativeMethods.Gdip.Ok, "GDI+ returned an error status: " + status.ToString(CultureInfo.InvariantCulture)); #endif } catch( Exception ex ){ if( ClientUtils.IsSecurityOrCriticalException( ex ) ) { throw; } Debug.Fail( "Exception thrown during Dispose: " + ex.ToString() ); } finally{ nativeImageAttributes = IntPtr.Zero; } } } ///. /// /// /// Cleans up Windows resources for this /// ~ImageAttributes() { Dispose(false); } ///. /// /// /// [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public object Clone() { IntPtr clone = IntPtr.Zero; int status = SafeNativeMethods.Gdip.GdipCloneImageAttributes( new HandleRef(this, nativeImageAttributes), out clone); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); return new ImageAttributes(clone); } /* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future. void SetToIdentity() { SetToIdentity(ColorAdjustType.Default); } void SetToIdentity(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesToIdentity(new HandleRef(this, nativeImageAttributes), type); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } void Reset() { Reset(ColorAdjustType.Default); } void Reset(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipResetImageAttributes(new HandleRef(this, nativeImageAttributes), type); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } */ ////// Creates an exact copy of this ///. /// /// /// public void SetColorMatrix(ColorMatrix newColorMatrix) { SetColorMatrix(newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default); } ////// Sets the 5 X 5 color adjust matrix to the /// specified ///. /// /// /// public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag flags) { SetColorMatrix(newColorMatrix, flags, ColorAdjustType.Default); } ////// Sets the 5 X 5 color adjust matrix to the specified 'Matrix' with the specified 'ColorMatrixFlags'. /// ////// /// public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag mode, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorMatrix( new HandleRef(this, nativeImageAttributes), type, true, newColorMatrix, null, mode); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ////// Sets the 5 X 5 color adjust matrix to the specified 'Matrix' with the /// specified 'ColorMatrixFlags'. /// ////// /// Clears the color adjust matrix to all /// zeroes. /// public void ClearColorMatrix() { ClearColorMatrix(ColorAdjustType.Default); } ////// /// public void ClearColorMatrix(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorMatrix( new HandleRef(this, nativeImageAttributes), type, false, null, null, ColorMatrixFlag.Default); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ////// Clears the color adjust matrix. /// ////// /// public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix) { SetColorMatrices(newColorMatrix, grayMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default); } ////// Sets a color adjust matrix for image colors /// and a separate gray scale adjust matrix for gray scale values. /// ////// /// public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags) { SetColorMatrices(newColorMatrix, grayMatrix, flags, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag mode, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorMatrix( new HandleRef(this, nativeImageAttributes), type, true, newColorMatrix, grayMatrix, mode); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetThreshold(float threshold) { SetThreshold(threshold, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetThreshold(float threshold, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesThreshold( new HandleRef(this, nativeImageAttributes), type, true, threshold); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearThreshold() { ClearThreshold(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearThreshold(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesThreshold( new HandleRef(this, nativeImageAttributes), type, false, 0.0f); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetGamma(float gamma) { SetGamma(gamma, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetGamma(float gamma, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesGamma( new HandleRef(this, nativeImageAttributes), type, true, gamma); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearGamma() { ClearGamma(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearGamma(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesGamma( new HandleRef(this, nativeImageAttributes), type, false, 0.0f); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetNoOp() { SetNoOp(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetNoOp(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesNoOp( new HandleRef(this, nativeImageAttributes), type, true); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearNoOp() { ClearNoOp(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearNoOp(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesNoOp( new HandleRef(this, nativeImageAttributes), type, false); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetColorKey(Color colorLow, Color colorHigh) { SetColorKey(colorLow, colorHigh, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetColorKey(Color colorLow, Color colorHigh, ColorAdjustType type) { int lowInt = colorLow.ToArgb(); int highInt = colorHigh.ToArgb(); int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorKeys( new HandleRef(this, nativeImageAttributes), type, true, lowInt, highInt); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearColorKey() { ClearColorKey(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearColorKey(ColorAdjustType type) { int zero = 0; int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorKeys( new HandleRef(this, nativeImageAttributes), type, false, zero, zero); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetOutputChannel(ColorChannelFlag flags) { SetOutputChannel(flags, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetOutputChannel(ColorChannelFlag flags, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannel( new HandleRef(this, nativeImageAttributes), type, true, flags); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearOutputChannel() { ClearOutputChannel(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearOutputChannel(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannel( new HandleRef(this, nativeImageAttributes), type, false, ColorChannelFlag.ColorChannelLast); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetOutputChannelColorProfile(String colorProfileFilename) { SetOutputChannelColorProfile(colorProfileFilename, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetOutputChannelColorProfile(String colorProfileFilename, ColorAdjustType type) { IntSecurity.DemandReadFileIO(colorProfileFilename); int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannelColorProfile( new HandleRef(this, nativeImageAttributes), type, true, colorProfileFilename); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearOutputChannelColorProfile() { ClearOutputChannel(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearOutputChannelColorProfile(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannel( new HandleRef(this, nativeImageAttributes), type, false, ColorChannelFlag.ColorChannelLast); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetRemapTable(ColorMap[] map) { SetRemapTable(map, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetRemapTable(ColorMap[] map, ColorAdjustType type) { int index = 0; int mapSize = map.Length; int size = 4; // Marshal.SizeOf(index.GetType()); IntPtr memory = Marshal.AllocHGlobal(mapSize*size*2); try { for (index=0; index[To be supplied.] ////// /// public void ClearRemapTable() { ClearRemapTable(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearRemapTable(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesRemapTable( new HandleRef(this, nativeImageAttributes), type, false, 0, NativeMethods.NullHandleRef); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetBrushRemapTable(ColorMap[] map) { SetRemapTable(map, ColorAdjustType.Brush); } ///[To be supplied.] ////// /// public void ClearBrushRemapTable() { ClearRemapTable(ColorAdjustType.Brush); } ///[To be supplied.] ////// /// public void SetWrapMode(WrapMode mode) { SetWrapMode(mode, new Color(), false); } ///[To be supplied.] ////// /// public void SetWrapMode(WrapMode mode, Color color) { SetWrapMode(mode, color, false); } ///[To be supplied.] ////// /// public void SetWrapMode(WrapMode mode, Color color, bool clamp) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesWrapMode( new HandleRef(this, nativeImageAttributes), (int)mode, color.ToArgb(), clamp); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void GetAdjustedPalette(ColorPalette palette, ColorAdjustType type) { // does inplace adjustment IntPtr memory = palette.ConvertToMemory(); try { int status = SafeNativeMethods.Gdip.GdipGetImageAttributesAdjustedPalette( new HandleRef(this, nativeImageAttributes), new HandleRef(null, memory), type); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } palette.ConvertFromMemory(memory); } finally { if(memory != IntPtr.Zero) { Marshal.FreeHGlobal(memory); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //[To be supplied.] ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing.Imaging { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.Drawing; using System.ComponentModel; using Microsoft.Win32; using System.Drawing.Drawing2D; using System.Drawing.Internal; using System.Globalization; using System.Runtime.Versioning; // sdkinc\GDIplusImageAttributes.h // There are 5 possible sets of color adjustments: // ColorAdjustDefault, // ColorAdjustBitmap, // ColorAdjustBrush, // ColorAdjustPen, // ColorAdjustText, // Bitmaps, Brushes, Pens, and Text will all use any color adjustments // that have been set into the default ImageAttributes until their own // color adjustments have been set. So as soon as any "Set" method is // called for Bitmaps, Brushes, Pens, or Text, then they start from // scratch with only the color adjustments that have been set for them. // Calling Reset removes any individual color adjustments for a type // and makes it revert back to using all the default color adjustments // (if any). The SetToIdentity method is a way to force a type to // have no color adjustments at all, regardless of what previous adjustments // have been set for the defaults or for that type. ////// /// Contains information about how image colors /// are manipulated during rendering. /// [StructLayout(LayoutKind.Sequential)] public sealed class ImageAttributes : ICloneable, IDisposable { #if FINALIZATION_WATCH private string allocationSite = Graphics.GetAllocationStack(); #endif /* * Handle to native image attributes object */ internal IntPtr nativeImageAttributes; internal void SetNativeImageAttributes(IntPtr handle) { if (handle == IntPtr.Zero) throw new ArgumentNullException("handle"); nativeImageAttributes = handle; } ////// /// Initializes a new instance of the [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public ImageAttributes() { IntPtr newImageAttributes = IntPtr.Zero; int status = SafeNativeMethods.Gdip.GdipCreateImageAttributes(out newImageAttributes); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); SetNativeImageAttributes(newImageAttributes); } internal ImageAttributes(IntPtr newNativeImageAttributes) { SetNativeImageAttributes(newNativeImageAttributes); } ///class. /// /// /// Cleans up Windows resources for this /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } void Dispose(bool disposing) { #if FINALIZATION_WATCH if (!disposing && nativeImageAttributes != IntPtr.Zero) Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite); #endif if (nativeImageAttributes != IntPtr.Zero) { try{ #if DEBUG int status = #endif SafeNativeMethods.Gdip.GdipDisposeImageAttributes(new HandleRef(this, nativeImageAttributes)); #if DEBUG Debug.Assert(status == SafeNativeMethods.Gdip.Ok, "GDI+ returned an error status: " + status.ToString(CultureInfo.InvariantCulture)); #endif } catch( Exception ex ){ if( ClientUtils.IsSecurityOrCriticalException( ex ) ) { throw; } Debug.Fail( "Exception thrown during Dispose: " + ex.ToString() ); } finally{ nativeImageAttributes = IntPtr.Zero; } } } ///. /// /// /// Cleans up Windows resources for this /// ~ImageAttributes() { Dispose(false); } ///. /// /// /// [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public object Clone() { IntPtr clone = IntPtr.Zero; int status = SafeNativeMethods.Gdip.GdipCloneImageAttributes( new HandleRef(this, nativeImageAttributes), out clone); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); return new ImageAttributes(clone); } /* FxCop rule 'AvoidBuildingNonCallableCode' - Left here in case it is needed in the future. void SetToIdentity() { SetToIdentity(ColorAdjustType.Default); } void SetToIdentity(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesToIdentity(new HandleRef(this, nativeImageAttributes), type); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } void Reset() { Reset(ColorAdjustType.Default); } void Reset(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipResetImageAttributes(new HandleRef(this, nativeImageAttributes), type); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } */ ////// Creates an exact copy of this ///. /// /// /// public void SetColorMatrix(ColorMatrix newColorMatrix) { SetColorMatrix(newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default); } ////// Sets the 5 X 5 color adjust matrix to the /// specified ///. /// /// /// public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag flags) { SetColorMatrix(newColorMatrix, flags, ColorAdjustType.Default); } ////// Sets the 5 X 5 color adjust matrix to the specified 'Matrix' with the specified 'ColorMatrixFlags'. /// ////// /// public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag mode, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorMatrix( new HandleRef(this, nativeImageAttributes), type, true, newColorMatrix, null, mode); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ////// Sets the 5 X 5 color adjust matrix to the specified 'Matrix' with the /// specified 'ColorMatrixFlags'. /// ////// /// Clears the color adjust matrix to all /// zeroes. /// public void ClearColorMatrix() { ClearColorMatrix(ColorAdjustType.Default); } ////// /// public void ClearColorMatrix(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorMatrix( new HandleRef(this, nativeImageAttributes), type, false, null, null, ColorMatrixFlag.Default); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ////// Clears the color adjust matrix. /// ////// /// public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix) { SetColorMatrices(newColorMatrix, grayMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default); } ////// Sets a color adjust matrix for image colors /// and a separate gray scale adjust matrix for gray scale values. /// ////// /// public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags) { SetColorMatrices(newColorMatrix, grayMatrix, flags, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag mode, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorMatrix( new HandleRef(this, nativeImageAttributes), type, true, newColorMatrix, grayMatrix, mode); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetThreshold(float threshold) { SetThreshold(threshold, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetThreshold(float threshold, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesThreshold( new HandleRef(this, nativeImageAttributes), type, true, threshold); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearThreshold() { ClearThreshold(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearThreshold(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesThreshold( new HandleRef(this, nativeImageAttributes), type, false, 0.0f); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetGamma(float gamma) { SetGamma(gamma, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetGamma(float gamma, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesGamma( new HandleRef(this, nativeImageAttributes), type, true, gamma); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearGamma() { ClearGamma(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearGamma(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesGamma( new HandleRef(this, nativeImageAttributes), type, false, 0.0f); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetNoOp() { SetNoOp(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetNoOp(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesNoOp( new HandleRef(this, nativeImageAttributes), type, true); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearNoOp() { ClearNoOp(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearNoOp(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesNoOp( new HandleRef(this, nativeImageAttributes), type, false); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetColorKey(Color colorLow, Color colorHigh) { SetColorKey(colorLow, colorHigh, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetColorKey(Color colorLow, Color colorHigh, ColorAdjustType type) { int lowInt = colorLow.ToArgb(); int highInt = colorHigh.ToArgb(); int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorKeys( new HandleRef(this, nativeImageAttributes), type, true, lowInt, highInt); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearColorKey() { ClearColorKey(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearColorKey(ColorAdjustType type) { int zero = 0; int status = SafeNativeMethods.Gdip.GdipSetImageAttributesColorKeys( new HandleRef(this, nativeImageAttributes), type, false, zero, zero); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetOutputChannel(ColorChannelFlag flags) { SetOutputChannel(flags, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetOutputChannel(ColorChannelFlag flags, ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannel( new HandleRef(this, nativeImageAttributes), type, true, flags); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearOutputChannel() { ClearOutputChannel(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearOutputChannel(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannel( new HandleRef(this, nativeImageAttributes), type, false, ColorChannelFlag.ColorChannelLast); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetOutputChannelColorProfile(String colorProfileFilename) { SetOutputChannelColorProfile(colorProfileFilename, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetOutputChannelColorProfile(String colorProfileFilename, ColorAdjustType type) { IntSecurity.DemandReadFileIO(colorProfileFilename); int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannelColorProfile( new HandleRef(this, nativeImageAttributes), type, true, colorProfileFilename); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void ClearOutputChannelColorProfile() { ClearOutputChannel(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearOutputChannelColorProfile(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannel( new HandleRef(this, nativeImageAttributes), type, false, ColorChannelFlag.ColorChannelLast); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetRemapTable(ColorMap[] map) { SetRemapTable(map, ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void SetRemapTable(ColorMap[] map, ColorAdjustType type) { int index = 0; int mapSize = map.Length; int size = 4; // Marshal.SizeOf(index.GetType()); IntPtr memory = Marshal.AllocHGlobal(mapSize*size*2); try { for (index=0; index[To be supplied.] ////// /// public void ClearRemapTable() { ClearRemapTable(ColorAdjustType.Default); } ///[To be supplied.] ////// /// public void ClearRemapTable(ColorAdjustType type) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesRemapTable( new HandleRef(this, nativeImageAttributes), type, false, 0, NativeMethods.NullHandleRef); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void SetBrushRemapTable(ColorMap[] map) { SetRemapTable(map, ColorAdjustType.Brush); } ///[To be supplied.] ////// /// public void ClearBrushRemapTable() { ClearRemapTable(ColorAdjustType.Brush); } ///[To be supplied.] ////// /// public void SetWrapMode(WrapMode mode) { SetWrapMode(mode, new Color(), false); } ///[To be supplied.] ////// /// public void SetWrapMode(WrapMode mode, Color color) { SetWrapMode(mode, color, false); } ///[To be supplied.] ////// /// public void SetWrapMode(WrapMode mode, Color color, bool clamp) { int status = SafeNativeMethods.Gdip.GdipSetImageAttributesWrapMode( new HandleRef(this, nativeImageAttributes), (int)mode, color.ToArgb(), clamp); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ///[To be supplied.] ////// /// public void GetAdjustedPalette(ColorPalette palette, ColorAdjustType type) { // does inplace adjustment IntPtr memory = palette.ConvertToMemory(); try { int status = SafeNativeMethods.Gdip.GdipGetImageAttributesAdjustedPalette( new HandleRef(this, nativeImageAttributes), new HandleRef(null, memory), type); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } palette.ConvertFromMemory(memory); } finally { if(memory != IntPtr.Zero) { Marshal.FreeHGlobal(memory); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ObjectDataProvider.cs
- SelectedCellsChangedEventArgs.cs
- InheritanceRules.cs
- HttpModuleActionCollection.cs
- X509CertificateTokenFactoryCredential.cs
- WorkflowOperationBehavior.cs
- ToolStripContainer.cs
- FolderLevelBuildProvider.cs
- CodeMemberEvent.cs
- NestedContainer.cs
- CheckBoxAutomationPeer.cs
- VirtualDirectoryMappingCollection.cs
- ValidateNames.cs
- Content.cs
- PreviewPrintController.cs
- FixedBufferAttribute.cs
- WpfXamlLoader.cs
- CustomWebEventKey.cs
- DataKeyArray.cs
- UTF32Encoding.cs
- ActiveXSite.cs
- StatusStrip.cs
- _AutoWebProxyScriptWrapper.cs
- ApplicationCommands.cs
- PassportAuthenticationEventArgs.cs
- StatusBarDrawItemEvent.cs
- StaticContext.cs
- IntegerValidatorAttribute.cs
- SharedDp.cs
- ObfuscationAttribute.cs
- MenuCommand.cs
- SpeechRecognizer.cs
- LayoutUtils.cs
- TextBoxView.cs
- IncrementalReadDecoders.cs
- NewArrayExpression.cs
- BrushConverter.cs
- PointCollectionValueSerializer.cs
- DataRow.cs
- CapabilitiesPattern.cs
- DbDataRecord.cs
- SamlAuthorityBinding.cs
- COAUTHINFO.cs
- QilVisitor.cs
- CompilerWrapper.cs
- Size.cs
- SimpleMailWebEventProvider.cs
- SiteMapPath.cs
- ping.cs
- Range.cs
- TextEditor.cs
- HttpContext.cs
- ADMembershipProvider.cs
- UpDownBase.cs
- GridViewRowPresenter.cs
- _FtpControlStream.cs
- ProviderException.cs
- PreviousTrackingServiceAttribute.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- ReceiveActivityDesignerTheme.cs
- RemoteWebConfigurationHostStream.cs
- XmlSchemaAttributeGroupRef.cs
- PriorityQueue.cs
- WindowsTitleBar.cs
- DemultiplexingClientMessageFormatter.cs
- ManipulationPivot.cs
- ThreadNeutralSemaphore.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- Certificate.cs
- EdmFunction.cs
- PropertyChangedEventArgs.cs
- PerformanceCounterPermissionEntry.cs
- HtmlTableCell.cs
- EntityObject.cs
- PhoneCallDesigner.cs
- TextSpan.cs
- OleDbParameterCollection.cs
- StyleTypedPropertyAttribute.cs
- XD.cs
- XmlSchemaElement.cs
- StreamingContext.cs
- ViewCellSlot.cs
- ConfigXmlText.cs
- ClientSettingsSection.cs
- MenuScrollingVisibilityConverter.cs
- CatalogZoneBase.cs
- HostUtils.cs
- TableCellCollection.cs
- IPPacketInformation.cs
- LifetimeServices.cs
- SyndicationCategory.cs
- ValueCollectionParameterReader.cs
- WebPartManagerInternals.cs
- QueryExpr.cs
- WebPartChrome.cs
- AnimationStorage.cs
- MatrixTransform.cs
- MediaContextNotificationWindow.cs
- XPathParser.cs
- Size3D.cs