ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CMYK
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

pierrotsc

USA
499 Posts

Posted - May 11 2013 :  19:23:19  Show Profile  Reply
First, how do I convert an image from RGB to CMYK and then, is it possible to split it into 4 layers? I know in RGB, I can split into Red, Green and blue layers.
Thanks.
P

fab

1310 Posts

Posted - May 14 2013 :  03:52:26  Show Profile  Reply
You can convert the pixel format from RGB to CMYK with:

ImageEnView.LegacyBitmap := false; // tells: don't use TBitmap
ImageEnView.IEBitmap.PixelFormat := ieCMYK;

You can extract CMYK pixel with:

CMYK := ImageEnView.IEBitmap.Pixels_ieCMYK[col, row];

CMYK is typed as TCMYK.
To create 4 layers, you have to loop among all pixels:

var
  col, row: integer;
  w, h: integer;
begin
  // layer 0 (CMYK image, you can also load native CMYK image)
  ImageEnView1.LegacyBitmap := false;
  ImageEnView1.IO.LoadFromFile('input.jpg');
  ImageEnView1.IEBitmap.PixelFormat := ieCMYK;

  w := ImageEnView1.IEBitmap.Width;
  h := ImageEnView1.IEBitmap.Height;

  ImageEnView1.LayersAdd(w, h, ie8g); // layer 1 = C
  ImageEnView1.LayersAdd(w, h, ie8g); // layer 2 = C
  ImageEnView1.LayersAdd(w, h, ie8g); // layer 3 = C
  ImageEnView1.LayersAdd(w, h, ie8g); // layer 4 = C

  for row := 0 to h - 1 do
  begin
    for col := 0 to w - 1 do
    begin
      with ImageEnView1.Layers[0].Bitmap.Pixels_ieCMYK[col, row] do
      begin
        ImageEnView1.Layers[1].Bitmap.Pixels_ie8[col, row] := c;
        ImageEnView1.Layers[2].Bitmap.Pixels_ie8[col, row] := m;
        ImageEnView1.Layers[3].Bitmap.Pixels_ie8[col, row] := y;
        ImageEnView1.Layers[4].Bitmap.Pixels_ie8[col, row] := k;
      end;
    end;
  end;
  
end;

Go to Top of Page

pierrotsc

USA
499 Posts

Posted - May 14 2013 :  05:14:47  Show Profile  Reply
Thank you..Someone told me that if I invert the RGB channels, I would get CMY

Maybe it is easier this way..
P
Go to Top of Page

fab

1310 Posts

Posted - May 14 2013 :  06:56:39  Show Profile  Reply
Maybe it means:

C = 255 - R
M = 255 - G
Y = 255 - B

But this is very poor RGB->CMY conversion (for the K you need another step).
Go to Top of Page

pierrotsc

USA
499 Posts

Posted - May 15 2013 :  04:08:40  Show Profile  Reply
in the color wheel, if you invert the red channel, you should get cyan.
So I use the proc.negative command. I'll do more testing.
PO
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: