Search Docs
Loading...
Skip to content

CMYK Colors

Work with CMYK colors in CE.SDK for professional print production workflows with support for color space conversion and tint control.

8 mins
estimated time
GitHub

CMYK (Cyan, Magenta, Yellow, Key/Black) is the standard color model for print production. Unlike sRGB, which is additive and designed for screens, CMYK uses subtractive color mixing to represent how inks combine on paper. Android represents CMYK values with CMYKColor, so the same color APIs can work with sRGB, CMYK, and spot colors.

This guide covers how to create CMYK colors, apply them to fills, strokes, and drop shadows, use the tint value, read colors back, convert between color spaces, and use CMYK in gradients.

Understanding CMYK Colors#

When to Use CMYK#

Use CMYK colors when preparing designs for print workflows or when a print service provider gives you CMYK values. Screen previews convert CMYK to sRGB for display, so use proofing from your production print workflow when exact output appearance matters.

A CMYK color in CE.SDK has five properties:

  • c (Cyan): 0F to 1F
  • m (Magenta): 0F to 1F
  • y (Yellow): 0F to 1F
  • k (Key/Black): 0F to 1F
  • tint: 0F to 1F (controls overall color intensity)

Creating CMYK Colors#

Create a CMYK color with Color.fromCMYK(). Every component ranges from 0F to 1F.

// CMYK components (c, m, y, k) and tint all range from 0F to 1F.
val cmykCyan = Color.fromCMYK(c = 1F, m = 0F, y = 0F, k = 0F, tint = 1F)
val cmykMagenta = Color.fromCMYK(c = 0F, m = 1F, y = 0F, k = 0F, tint = 1F)
val cmykYellow = Color.fromCMYK(c = 0F, m = 0F, y = 1F, k = 0F, tint = 1F)
val cmykBlack = Color.fromCMYK(c = 0F, m = 0F, y = 0F, k = 1F, tint = 1F)

Applying CMYK Colors to Fills#

Apply a CMYK color to a color fill with engine.block.setColor() on the fill’s "fill/color/value" property. Create the fill with FillType.Color, assign it to a block, then set the CMYK value.

val fillBlock = engine.block.create(DesignBlockType.Graphic)
engine.block.setShape(fillBlock, shape = engine.block.createShape(ShapeType.Rect))
val fill = engine.block.createFill(FillType.Color)
engine.block.setFill(fillBlock, fill = fill)
// Color fill values currently use the generic color property key.
engine.block.setColor(fill, property = "fill/color/value", value = cmykCyan)

The same setColor() method accepts RGBAColor, CMYKColor, and SpotColor values, so you do not need a separate code path for each color space.

Using the Tint Property#

The tint value scales the color’s intensity without changing its CMYK components. A tint of 1F applies the full color; 0.5F scales it down.

// Tint scales the color intensity without changing the CMYK components.
val cmykHalfMagenta = Color.fromCMYK(c = 0F, m = 1F, y = 0F, k = 0F, tint = 0.5F)
val tintedBlock = engine.block.create(DesignBlockType.Graphic)
engine.block.setShape(tintedBlock, shape = engine.block.createShape(ShapeType.Rect))
val tintedFill = engine.block.createFill(FillType.Color)
engine.block.setFill(tintedBlock, fill = tintedFill)
engine.block.setColor(tintedFill, property = "fill/color/value", value = cmykHalfMagenta)

Applying CMYK to Strokes#

Enable the stroke and set its width, then assign a CMYK color with engine.block.setStrokeColor().

val strokeBlock = engine.block.create(DesignBlockType.Graphic)
engine.block.setShape(strokeBlock, shape = engine.block.createShape(ShapeType.Rect))
engine.block.setStrokeEnabled(strokeBlock, enabled = true)
engine.block.setStrokeWidth(strokeBlock, width = 8F)
val cmykStrokeColor = Color.fromCMYK(c = 0.8F, m = 0.2F, y = 0F, k = 0.1F, tint = 1F)
engine.block.setStrokeColor(strokeBlock, color = cmykStrokeColor)

Applying CMYK to Drop Shadows#

Enable the drop shadow, configure its offset and blur radius, then assign a CMYK color with engine.block.setDropShadowColor().

val shadowBlock = engine.block.create(DesignBlockType.Graphic)
engine.block.setShape(shadowBlock, shape = engine.block.createShape(ShapeType.Rect))
engine.block.setDropShadowEnabled(shadowBlock, enabled = true)
engine.block.setDropShadowOffsetX(shadowBlock, offsetX = 8F)
engine.block.setDropShadowOffsetY(shadowBlock, offsetY = 8F)
engine.block.setDropShadowBlurRadiusX(shadowBlock, blurRadiusX = 12F)
engine.block.setDropShadowBlurRadiusY(shadowBlock, blurRadiusY = 12F)
val cmykShadowColor = cmykBlack
engine.block.setDropShadowColor(shadowBlock, color = cmykShadowColor)

Reading CMYK Colors#

engine.block.getColor() returns the shared Color type. Use Kotlin type checking to handle CMYKColor values and read their components.

val readBlock = engine.block.create(DesignBlockType.Graphic)
engine.block.setShape(readBlock, shape = engine.block.createShape(ShapeType.Rect))
val readFill = engine.block.createFill(FillType.Color)
engine.block.setFill(readBlock, fill = readFill)
val cmykOrange = Color.fromCMYK(c = 0F, m = 0.5F, y = 1F, k = 0F, tint = 1F)
engine.block.setColor(readFill, property = "fill/color/value", value = cmykOrange)
val retrievedColor = engine.block.getColor(readFill, property = "fill/color/value")
val retrievedCmyk = when (retrievedColor) {
is CMYKColor -> retrievedColor
else -> error("Expected a CMYK color, got $retrievedColor")
}
println(
"CMYK Color - C: ${retrievedCmyk.c}, M: ${retrievedCmyk.m}, " +
"Y: ${retrievedCmyk.y}, K: ${retrievedCmyk.k}, Tint: ${retrievedCmyk.tint}",
)

Converting Between Color Spaces#

Use engine.editor.convertColorToColorSpace() with ColorSpace.CMYK or ColorSpace.SRGB to convert between color spaces.

// Converting CMYK to sRGB reads the document CMYK profile, which is a resource. Load it once
// first, so the conversion does not have to handle COLOR.PROFILE_NOT_LOADED.
engine.editor.loadColorProfiles()
val rgbBlue = Color.fromRGBA(r = 0.2F, g = 0.4F, b = 0.9F, a = 1F)
val convertedCmyk = engine.editor.convertColorToColorSpace(
color = rgbBlue,
colorSpace = ColorSpace.CMYK,
)
val cmykGreen = Color.fromCMYK(c = 0.7F, m = 0F, y = 1F, k = 0.2F, tint = 1F)
val convertedSrgb = engine.editor.convertColorToColorSpace(
color = cmykGreen,
colorSpace = ColorSpace.SRGB,
)

Conversions may not be perfectly reversible because sRGB and CMYK have different gamuts. Some sRGB colors cannot be represented exactly in CMYK and vice versa.

Using CMYK in Gradients#

CMYK colors work in gradient color stops. Create a linear gradient fill and pass GradientColorStop values whose color is a CMYK color.

val gradientBlock = engine.block.create(DesignBlockType.Graphic)
engine.block.setShape(gradientBlock, shape = engine.block.createShape(ShapeType.Rect))
val gradientFill = engine.block.createFill(FillType.LinearGradient)
engine.block.setFill(gradientBlock, fill = gradientFill)
val gradientStops = listOf(
GradientColorStop(stop = 0F, color = cmykCyan),
GradientColorStop(stop = 0.5F, color = cmykMagenta),
GradientColorStop(stop = 1F, color = cmykYellow),
)
// Gradient fills currently expose their stops through the generic property key.
engine.block.setGradientColorStops(
gradientFill,
property = "fill/gradient/colors",
colorStops = gradientStops,
)

Setting the Document CMYK Profile#

CE.SDK previews CMYK colors through an ICC profile. The bundled default profile models a US press condition. For another print condition, for example European coated paper, set the CMYK profile of the document to the profile your printer supplies.

The engine picks the CMYK profile in this order:

  1. A CMYK image with its own embedded ICC profile uses that profile, for that image only.
  2. The CMYK profile of the document, when you set one.
  3. The profile at the fallbackCMYKProfileUri setting.
  4. The bundled default profile, when that setting is empty.

The document profile and its conversion settings belong to engine.scene. They are saved with the scene and bundled into scene archives. Undo and redo do not change these properties. The fallbackCMYKProfileUri editor setting belongs to the current editor environment.

Raster exports use the document profile for CMYK-to-RGB conversion. A scene whose scene/colorConversionMode is Legacy keeps its previous conversion until you set the property to Managed.

// Load the profile from a URI. The call returns once the profile is in effect.
val defaultCMYK = ProfileSlot(ProfileRole.DEFAULT, ProfileColorSpace.CMYK)
engine.scene.setDocumentColorProfile(slot = defaultCMYK, uri = Uri.parse("https://example.com/profiles/PSOcoated_v3.icc"))
// Or pass the profile bytes directly, in a direct ByteBuffer.
val bytes = context.assets.open("PSOcoated_v3.icc").use { it.readBytes() }
val buffer = ByteBuffer.allocateDirect(bytes.size).apply {
put(bytes)
rewind()
}
engine.scene.setDocumentColorProfileFromData(slot = defaultCMYK, data = buffer)
// Read what the document names, and go back to the fallback profile.
val info = engine.scene.getDocumentColorProfileInfo(defaultCMYK) // DocumentColorProfileInfo
engine.scene.removeDocumentColorProfile(defaultCMYK)
engine.editor.loadColorProfiles()
// Configure the conversion.
engine.scene.setColorRenderingIntent(intent = ColorRenderingIntent.PERCEPTUAL)
engine.scene.setBlackPointCompensationEnabled(enabled = false)

An assignment is atomic. While a profile loads, the previous profile stays in effect. When the profile cannot be loaded, is not a valid ICC profile, or is not a CMYK profile, the call fails and the previous profile stays in effect. engine.scene.getDocumentColorProfileInfo(defaultCMYK) returns the content hash of the profile the document names, its name from the ICC description, and the uri it is named by, and throws when none is set. A save and load rewrites the URI. A profile that has not finished loading reports no name. engine.scene.removeDocumentColorProfile(defaultCMYK) goes back to the fallback profile.

A profile set from bytes is saved as a buffer:// URI when you save the scene to a string, and only the same engine can read that URI. Save the scene to an archive to keep the profile bytes with the scene. To save a URL instead, upload the bytes that findAllTransientResources lists and call relocateResource before you save.

You can also set how colors outside the destination gamut are mapped, with the rendering intent, and whether black point compensation is on. The defaults are relative colorimetric intent with black point compensation.

Managing Document Profile Slots#

Use setDocumentColorProfile(slot, uri) to assign a profile by role and component space, or setDocumentColorProfileFromData(slot, data) to assign its bytes. A document has six independent slots: Default and Output, each with RGB, CMYK and Gray. For example, ProfileSlot(ProfileRole.OUTPUT, ProfileColorSpace.CMYK) selects the Output CMYK slot.

Read a slot with getDocumentColorProfileInfo(slot) and remove it with removeDocumentColorProfile(slot). The getter returns the stored content hash, URI and loaded name. It throws when the slot is empty and does not load the profile or report a fallback. Removal also supersedes a pending assignment to that slot. An assignment or removal in another slot does not cancel it; replacing the scene supersedes all pending assignments.

Profiles in every slot persist in scenes and archives. Default CMYK controls ordinary managed conversion. Soft proofing can also use Output CMYK, Output RGB and Default RGB for the live canvas. An export reads the Output slot of its color space when its outputProfileMode is OutputProfileMode.CONVERT or OutputProfileMode.ASSIGN, and a PDF export also reads it with embedProfiles = true. A profile must match its slot’s component space; a failed assignment keeps the previous profile. Profiles assigned from bytes need an archive to carry their bytes into another engine instance.

The CMYK profile functions are deprecated. Use the document color profile methods with the Default CMYK slot for assignment, information and removal. Use engine.editor.loadColorProfiles() instead of loadCMYKProfile() to wait for the profiles of the document. It opens every profile the document names and resolves the Default CMYK fallback. Only the Default CMYK result decides success or failure. A profile of another slot that fails to load is logged and does not fail the call.

Soft Proofing#

Soft proofing simulates the selected output color space after the artwork has been composed. Turn it on with engine.editor.setSoftProofEnabled(), and choose ProfileColorSpace.CMYK or ProfileColorSpace.RGB with engine.editor.setSoftProofColorSpace(). Proofing is off by default, and the color space defaults to ProfileColorSpace.CMYK. Gray throws an EngineException and keeps the previous color space.

engine.editor.setSoftProofColorSpace(ProfileColorSpace.CMYK)
engine.editor.setSoftProofEnabled(true)

Switch to RGB without disabling proofing first:

engine.editor.setSoftProofColorSpace(ProfileColorSpace.RGB)

The target selects a profile of the same component space:

Target First choice Second choice When both slots are empty
CMYK Output CMYK Default CMYK fallbackCMYKProfileUri, or the bundled CMYK profile when that setting is empty
RGB Output RGB Default RGB Built-in sRGB

Assign an Output profile through the document profile methods above. Both Output slots can hold profiles at the same time. Only an empty slot falls through to the next choice. An assigned profile that fails to load, or a configured CMYK fallback that fails, produces a proof error instead of selecting another profile.

Preview Scope#

The proof applies once inside visible page trims, including where pages overlap. A front page’s bleed keeps its ordinary appearance even over another page’s trim. Bleed artwork, crop overflow, overlays, gizmos, page decorations and loading or error visuals stay unproofed. Stored colors, exports and thumbnails do not change.

RGB proofing clips colors to the target RGB gamut. Choosing the working RGB profile may produce no visible difference. This preview simulates composed RGB artwork; it does not preserve original ink separations or guarantee K-only black. It does not simulate overprint or paper white, and it does not certify printed color accuracy.

Loading and Errors#

While a selected profile or a higher-priority replacement loads, affected content blocks report pending through the block-state API. A pending replacement can keep displaying the proof of the previous committed profile. An unrelated or lower-priority load does not block a usable selection. A rejected assignment leaves the previous profile in place and clears that candidate’s proof wait.

A profile can load successfully but lack a conversion needed for proofing. In that case, it stays assigned and proofing stays enabled, but affected blocks report an error state of type SOFT_PROOF. The canvas shows ordinary unproofed content until the profile or conversion settings make the proof usable. Disabling proofing clears proof-only pending and error state. It does not cancel a profile assignment started by your application or clear an image, font or other content error.

Proof-only pending and error states do not delay or fail exports or thumbnails. Those operations still wait for the resources their own content needs.

Proof Lifecycle#

Soft proofing belongs to the editor, not to the scene. Scene and archive saves omit it, and undo and redo do not change it. Creating a scene, loading a scene and applying a template turn proofing off and reset the color space to ProfileColorSpace.CMYK. A setActiveHistory call that switches to another scene does the same by the next update. A failed scene load and a block import keep both values. Use engine.editor.onStateChanged() to observe each change, a reset included. CE.SDK adds no proofing control, so connect your own controls to these methods.

Troubleshooting#

Colors Look Different on Screen vs. Print#

Screen previews convert CMYK to sRGB using a standard conversion. Android PDF export writes DeviceRGB unless you set outputColorSpace = ProfileColorSpace.CMYK. Use calibrated proofing from your print workflow when exact print appearance matters.

Tint Not Having the Expected Effect#

The tint value must be between 0F and 1F. On Android, values below 1F do not lower alpha; the sRGB preview blends the color toward white and stays opaque.

API Reference#

Method Description
Color.fromCMYK(c=_, m=_, y=_, k=_, tint=_) Create a CMYK color with normalized components and tint.
engine.block.setColor(block=_, property="fill/color/value", value=_) Set a color property on a fill. Accepts any Color type.
engine.block.getColor(block=_, property="fill/color/value") Get the current color value from a property. Returns Color.
engine.editor.convertColorToColorSpace(color=_, colorSpace=_) Convert a color between ColorSpace.SRGB and ColorSpace.CMYK.
engine.block.createFill(fillType=_) Create a fill. Use FillType.Color for solid fills or FillType.LinearGradient, FillType.RadialGradient, or FillType.ConicalGradient for gradients.
engine.block.setFill(block=_, fill=_) Assign a fill to a block.
engine.block.setStrokeColor(block=_, color=_) Set the stroke color on a block.
engine.block.setDropShadowColor(block=_, color=_) Set the drop shadow color on a block.
engine.block.setGradientColorStops(block=_, property="fill/gradient/colors", colorStops=_) Set color stops on a gradient fill.
engine.editor.loadColorProfiles() Wait for every profile the document names and the Default CMYK fallback
engine.scene.setDocumentColorProfile(slot=_, uri=_) Load a CMYK ICC profile from a URI and make it the document profile
engine.scene.setDocumentColorProfileFromData(slot=_, data=_) Make the CMYK ICC profile in a direct ByteBuffer the document profile
engine.scene.getDocumentColorProfileInfo(defaultCMYK) Get the document CMYK profile info; throws if none is set
engine.scene.removeDocumentColorProfile(defaultCMYK) Remove the document CMYK profile and use the fallback profile
engine.scene.setColorRenderingIntent(intent=_) Set the rendering intent of CMYK conversion
engine.scene.setBlackPointCompensationEnabled(enabled=_) Turn black point compensation on or off
engine.block.create(blockType=_) Create a graphic block for a color example.
engine.block.createShape(type=_) Create the shape of a graphic block.
engine.block.setShape(block=_, shape=_) Assign a shape to a graphic block.
engine.block.setStrokeEnabled(block=_, enabled=_) Enable a block’s stroke.
engine.block.setStrokeWidth(block=_, width=_) Set the stroke width.
engine.block.setDropShadowEnabled(block=_, enabled=_) Enable a block’s drop shadow.
engine.block.setDropShadowOffsetX(block=_, offsetX=_) Set the shadow’s horizontal offset.
engine.block.setDropShadowOffsetY(block=_, offsetY=_) Set the shadow’s vertical offset.
engine.block.setDropShadowBlurRadiusX(block=_, blurRadiusX=_) Set the shadow’s horizontal blur radius.
engine.block.setDropShadowBlurRadiusY(block=_, blurRadiusY=_) Set the shadow’s vertical blur radius.
engine.editor.setSoftProofEnabled(enabled=_) Turn the live soft proof on or off.
engine.editor.setSoftProofColorSpace(colorSpace=_) Select the RGB or CMYK proof target.
engine.editor.isSoftProofEnabled() Read whether the live soft proof is on.
engine.editor.getSoftProofColorSpace() Read the proof target.
Type Description
CMYKColor CMYK color for print workflows. Components and tint range from 0F to 1F.
ColorSpace.CMYK / ColorSpace.SRGB Target color space for convertColorToColorSpace().
GradientColorStop Gradient stop with a color: Color and a stop: Float position.

Next Steps#

  • Spot Colors - Work with named spot colors for brand consistency and specialized printing
  • Color Conversion - Convert colors between sRGB, CMYK, and spot color spaces
  • Apply Colors - Apply colors to design elements programmatically