| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- //
- // System.Drawing.Imaging.ImageAttributes.cs
- //
- // Author:
- // Dennis Hayes ([email protected]) (stubbed out)
- // Jordi Mas i Hernàndez ([email protected])
- // Sanjay Gupta ([email protected])
- //
- // (C) 2002-4 Ximian, Inc. http://www.ximian.com
- //
- using System;
- using System.Drawing;
- namespace System.Drawing.Imaging
- {
- /// <summary>
- /// Summary description for ImageAttributes.
- /// </summary>
- public sealed class ImageAttributes : ICloneable, IDisposable {
-
- private IntPtr nativeImageAttr = IntPtr.Zero;
-
- internal IntPtr NativeObject{
- get{
- return nativeImageAttr;
- }
- }
-
- public ImageAttributes() {
-
-
- Status status = GDIPlus.GdipCreateImageAttributes(out nativeImageAttr);
-
- if (status != Status.Ok)
- throw new Exception ("Error calling GDIPlus.GdipCreateImageAttributes:" +status);
-
- Console.WriteLine("ImageAttributes().ImageAttributes()" + nativeImageAttr);
- }
- public void ClearBrushRemapTable()
- {
- ClearRemapTable (ColorAdjustType.Brush);
- }
- //Clears the color keys for all GDI+ objects
- public void ClearColorKey()
- {
- ClearColorKey (ColorAdjustType.Default);
- }
- public void ClearColorKey(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesColorKeys (nativeImageAttr,
- type, false, 0, 0);
-
- GDIPlus.CheckStatus (status);
- }
- public void ClearColorMatrix()
- {
- ClearColorMatrix (ColorAdjustType.Default);
- }
-
- public void ClearColorMatrix(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr,
- type, false, null, null, ColorMatrixFlag.Default);
-
- GDIPlus.CheckStatus (status);
- }
-
- public void ClearGamma()
- {
- ClearGamma (ColorAdjustType.Default);
- }
-
- public void ClearGamma(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesGamma (nativeImageAttr,
- type, false, 0);
-
- GDIPlus.CheckStatus (status);
- }
-
- public void ClearNoOp()
- {
- ClearNoOp (ColorAdjustType.Default);
- }
-
- public void ClearNoOp(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesNoOp (nativeImageAttr,
- type, false);
-
- GDIPlus.CheckStatus (status);
- }
- public void ClearOutputChannel()
- {
- ClearOutputChannel (ColorAdjustType.Default);
- }
-
- public void ClearOutputChannel(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesOutputChannel (nativeImageAttr,
- type, false, ColorChannelFlag.ColorChannelLast );
-
- GDIPlus.CheckStatus (status);
- }
- public void ClearOutputChannelColorProfile()
- {
- ClearOutputChannelColorProfile (ColorAdjustType.Default);
- }
-
- public void ClearOutputChannelColorProfile(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesOutputChannelColorProfile (nativeImageAttr,
- type, false, null);
-
- GDIPlus.CheckStatus (status);
- }
- public void ClearRemapTable()
- {
- ClearRemapTable (ColorAdjustType.Default);
- }
-
- public void ClearRemapTable(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr,
- type, false, 0, IntPtr.Zero);
-
- GDIPlus.CheckStatus (status);
- }
- public void ClearThreshold()
- {
- ClearThreshold (ColorAdjustType.Default);
- }
-
- public void ClearThreshold(ColorAdjustType type)
- {
- Status status = GDIPlus.GdipSetImageAttributesThreshold (nativeImageAttr,
- type, false, 0);
-
- GDIPlus.CheckStatus (status);
- }
- //Sets the color keys for all GDI+ objects
- public void SetColorKey(Color colorLow, Color colorHigh)
- {
-
- Status status = GDIPlus.GdipSetImageAttributesColorKeys(nativeImageAttr,
- ColorAdjustType.Default, true, colorLow.ToArgb(), colorHigh.ToArgb());
- if (status != Status.Ok)
- throw new Exception ("Error calling GDIPlus.GdipSetImageAttributesColorKeys:" +status);
- }
- public void SetColorMatrix(ColorMatrix colorMatrix) {
-
- Status status = GDIPlus.GdipSetImageAttributesColorMatrix(nativeImageAttr, ColorAdjustType.Default,
- true, colorMatrix, (ColorMatrix)null, ColorMatrixFlag.Default);
- if (status != Status.Ok)
- throw new Exception ("Error calling GDIPlus.SetColorMatrix:" +status);
- }
- public void SetColorMatrix(ColorMatrix colorMatrix, ColorMatrixFlag colorMatrixFlag) {
-
- Status status = GDIPlus.GdipSetImageAttributesColorMatrix(nativeImageAttr, ColorAdjustType.Default,
- true, colorMatrix, (ColorMatrix)null, colorMatrixFlag);
- if (status != Status.Ok)
- throw new Exception ("Error calling GDIPlus.SetColorMatrix:" +status);
-
- }
- public void SetColorMatrix(ColorMatrix colorMatrix, ColorMatrixFlag colorMatrixFlag, ColorAdjustType colorAdjustType) {
-
- Status status = GDIPlus.GdipSetImageAttributesColorMatrix(nativeImageAttr,colorAdjustType,
- true, colorMatrix, (ColorMatrix)null, colorMatrixFlag);
-
- if (status != Status.Ok)
- throw new Exception ("Error calling GDIPlus.SetColorMatrix:" +status);
- }
-
- void Dispose (bool disposing)
- {
- if (!disposing) return;
-
- Status status = GDIPlus.GdipDisposeImageAttributes(nativeImageAttr);
-
- if (status != Status.Ok)
- throw new Exception ("Error calling GDIPlus.GdipDisposeImageAttributes:" +status);
- else
- nativeImageAttr = IntPtr.Zero;
- }
- public void Dispose() {
-
- Dispose (true);
- System.GC.SuppressFinalize (this);
- }
- ~ImageAttributes() {
-
- Dispose (false);
- }
- [MonoTODO]
- object ICloneable.Clone()
- {
- throw new NotImplementedException ();
- }
- }
- }
|