El modelo de colores CMYK es estándar y se utiliza en la impresión OFFSET. En este artículo Cesar muestra cómo lograrlo desde GDI+.
Todos los ejemplos que se muestran a continuación utilizan la nueva biblioteca GDIPlus-X. GdiPlusX está aún en versión ALPHA, pero es realmente estable y fiable para hacer la gran mayoría de las tareas de GDI+. Descargue la versión más estable de Codeplex:
http://www.codeplex.com/Wiki/View.aspx?ProjectName=VFPX&title=GDIPlusX
* Inicia GdiPlusX
_SCREEN.AddProperty("System", NEWOBJECT("xfcSystem", LOCFILE("system.vcx","vcx")))
WITH _SCREEN.System.Drawing
* Crea un bitmap desde un archivo.
LOCAL loBmp as xfcBitmap
loBmp = .Bitmap.New(GETPICT())
* Crea un segundo Bitmap que va a recibir las imágenes transformadas
LOCAL loDestBmp as xfcBitmap
loDestBmp = .Bitmap.New(loBmp, loBmp.Width, loBmp.Height)
* Crea un objeto ImageAttributes.
LOCAL loImgAttributes as xfcImageAttributes
loImgAttributes = .Imaging.ImageAttributes.New()
* Inicia el objeto graphics para poder dibujar en la imagen creada
LOCAL loMyGraphics AS xfcGraphics
loMyGraphics = .Graphics.FromImage(loDestBmp)
* Crea un objeto Rectangle que se va a utilizar para dibujar las cuatro imágenes
* (todos los objetos son del mismo tamaño)
LOCAL loRect AS xfcRectangle
loRect = loDestBmp.GetBounds()
* Dibuja la imagen, mostrando la intensidad del canal CYAN.
loImgAttributes.SetOutputChannel(.Imaging.ColorChannelFlag.ColorChannelC, .Imaging.ColorAdjustType.Bitmap)
loMyGraphics.DrawImage(loBmp, loRect, loRect, .GraphicsUnit.Pixel, loImgAttributes)
loDestBmp.Save("C:\ChannelCyan.Png", .imaging.ImageFormat.Png)
* Dibuja la imagen, mostrando la intensidad del canal MAGENTA.
loImgAttributes.SetOutputChannel(.Imaging.ColorChannelFlag.ColorChannelM, .Imaging.ColorAdjustType.Bitmap)
loMyGraphics.DrawImage(loBmp, loRect, loRect, .GraphicsUnit.Pixel, loImgAttributes)
loDestBmp.Save("C:\ChannelMagenta.Png", .imaging.ImageFormat.Png)
* Dibuja la imagen, mostrando la intensidad del canal YELLOW.
loImgAttributes.SetOutputChannel(.Imaging.ColorChannelFlag.ColorChannelY, .Imaging.ColorAdjustType.Bitmap)
loMyGraphics.DrawImage(loBmp, loRect, loRect, .GraphicsUnit.Pixel, loImgAttributes)
loDestBmp.Save("C:\ChannelYellow.Png", .imaging.ImageFormat.Png)
* Dibuja la imagen, mostrando la intensidad del canal BLACK.
loImgAttributes.SetOutputChannel(.Imaging.ColorChannelFlag.ColorChannelK, .Imaging.ColorAdjustType.Bitmap)
loMyGraphics.DrawImage(loBmp, loRect, loRect, .GraphicsUnit.Pixel, loImgAttributes)
loDestBmp.Save("C:\ChannelBlack.Png", .imaging.ImageFormat.Png)
ENDWITH
RETURN
He aquí las salidas obtenidas para la figura Nymphs
Original

Celeste

Púrpura

Amarillo

Negro

En la carpeta Samples de GDIPlus-X encontrará el ejemplo ColorChannel.scx, que muestra además cómo trabajar con los canales de colores CMYK.

Enlaces relacionados:
What is CMYK? http://www.wisegeek.com/what-is-cmyk.htm
MSDN - ImageAttributes.SetOutputChannel Method http://msdn2.microsoft.com/en-gb/library/0a8xyx70.aspx
|