What does Windows error code 2022 (ERROR_INVALID_COLORINDEX) mean?

 
Previous Next
ERROR_COLORSPACE_MISMATCH ERROR_PROFILE_DOES_NOT_MATCH_DEVICE

ERROR_INVALID_COLORINDEX

The named color index is not present in the profile.

ERROR_INVALID_COLORINDEX is Win32 error 2022 (0x7E6). Named-color ICC profiles can expose colors by one-based index as well as by name. An index is meaningful only inside the exact profile version from which it was obtained; it is not a global palette number or a zero-based array offset.

Why named-color indices become invalid

  • application code passes zero or a value greater than the profile’s named-color count
  • an index saved for one profile is reused after the profile was replaced or reordered
  • a UI list is zero-based while ConvertIndexToColorName expects indices beginning with one
  • the handle refers to an ordinary device profile rather than an ICC named-color profile
  • a concurrent configuration change swaps the profile between enumeration and conversion

Named-color evidence

Log the profile path and hash, profile class, named-color count, requested index, caller’s zero/one-based convention, enumeration generation, associated device or document, and the API returning 2022. Color names may be proprietary production data, so record them only when policy permits and bound their length.

Diagnostic sequence

Open and validate the exact ICC profile, enumerate or inspect its named-color entries, and confirm the documented one-based index range. Reproduce by converting a known valid first and last index before testing the failing value.

Trace where the index was produced. If it came from another profile, persisted document, or user-visible list, compare profile identifiers and mapping rules. Do not repair the problem by subtracting or adding one until the API and UI conventions are both proven.

Recovery and stable storage

Refresh the list from the current profile and resolve the intended color by a stable name or application-owned identifier when possible. Reject an absent color explicitly rather than silently substituting the nearest index.

Persist the profile hash/version beside any stored index and invalidate mappings after profile updates. Production workflows should show the operator which named ink or spot color is unavailable because automatic substitution can change output materially.

Difference from a missing tag

ERROR_TAG_NOT_FOUND concerns an ICC tag-table entry. Error 2022 occurs after using a named-color profile and says the requested member index is not present in that profile’s color list.

Example

A packaging document stores index 14 from a vendor spot-color profile. The vendor installs a revised profile containing only 12 entries. Conversion returns 2022. Re-resolving the document’s saved color name against the new profile reveals that the spot color was removed.

References


Looking for a different code? Search another status or error code.