This function applies conversion to a single raster.
Declaration:
Copy Code | |
---|---|
AT_ERRCOUNT ACCUAPI IG_colorspace_conversion_apply_to_raster( HIGCSCONVERTER hCSConverter, const void* sourceRaster, void* resultRaster, AT_INT rasterLength ); |
Arguments:
hCSConverter | Handle of color space converter. |
sourceRaster | Raster to be converted. |
resultRaster | Raster to store conversion result. |
rasterLength | Number of PIXELS (not bytes!) in raster to convert. |
Return Value:
Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.
Supported Raster Image Formats:
All pixel formats supported by ImageGear Professional.
Sample:
None
Example:
Copy Code | |
---|---|
/* Use the color space converter to convert a CMYK raster to 24-bit RGB. Then fill a test image with it and save file. */AT_ERRCOUNT nErrcount; /* Number of errors on stack */ HIGCSCONVERTER hCSConv; /* Color space converter handle */ HIGEAR hImage; /* HIGEAR handle of image */ AT_INT depthsCMYK[] = { 8, 8, 8, 8 }; /* CMYK channel depths */ AT_INT depthsRGB[] = { 8, 8, 8 }; /* RGB channel depths */ HIGDIBINFO hDIBCMYK; /* CMYK DIB info handle */ HIGDIBINFO hDIBRGB; /* RGB DIB info handle */ AT_DIMENSION x, y, w = 64, h = 64; /* Test image dimensions */ AT_DIMENSION rasterSizeCMYK; /* CMYK raster size */ AT_DIMENSION rasterSizeRGB; /* RGB raster size */ LPAT_PIXEL lpRasterCMYK; /* CMYK raster data */ LPAT_PIXEL lpRasterRGB; /* RGB raster data */ /* Create CMYK test raster (solid yellow) */ nErrcount = IG_DIB_info_create(&hDIBCMYK, w, h, IG_COLOR_SPACE_ID_CMYK, 4, depthsCMYK); rasterSizeCMYK = IG_DIB_info_raster_size_get(hDIBCMYK); lpRasterCMYK = (LPAT_PIXEL) calloc(rasterSizeCMYK, 1); for (x = 0; x <= rasterSizeCMYK - 4; x += 4) lpRasterCMYK[x] = 255; /* Yellow */ /* Create RGB test image */ nErrcount = IG_DIB_info_create(&hDIBRGB, w, h, IG_COLOR_SPACE_ID_RGB, 3, depthsRGB); rasterSizeRGB = IG_DIB_info_raster_size_get(hDIBRGB); lpRasterRGB = (LPAT_PIXEL) malloc(rasterSizeRGB); nErrcount = IG_image_create(hDIBRGB, &hImage); /* Convert CMYK test raster to RGB raster */ nErrcount = IG_colorspace_conversion_create_from_dib_info( hDIBCMYK, IG_COLOR_SPACE_ID_RGB, depthsRGB, 3, NULL, &hCSConv); nErrcount = IG_colorspace_conversion_apply_to_raster( hCSConv, lpRasterCMYK, lpRasterRGB, w); nErrcount = IG_colorspace_conversion_destroy(hCSConv); /* Fill test image with converted raster */ for (y = 0; y < h; y++) nErrcount = IG_DIB_raster_set(hImage, y, lpRasterRGB, IG_PIXEL_UNPACKED); /* Save test image to a file and clean up */ nErrcount = IG_save_file(hImage, "test.bmp", IG_SAVE_BMP_UNCOMP); nErrcount = IG_DIB_info_delete(hDIBRGB); nErrcount = IG_DIB_info_delete(hDIBCMYK); nErrcount = IG_image_delete(hImage); free(lpRasterCMYK); free(lpRasterRGB); |
Remarks:
The resultRaster argument should be sufficient to store the converted pixels. If the result raster is run-ends, the store must be suitable to contain the most capacious case. The rasterLength argument specifies the quantity of pixels (not bytes!) in the raster.