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
 percent color of all channel
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

MMP112

Iran
3 Posts

Posted - Aug 24 2016 :  09:49:17  Show Profile  Reply
we have a psd file with 5 channel color contain the
1.blue
2.pink
3.yellow
4.brown
5.gold

i need to calculated the percent used of the channels color in the files seem average in photoshop.
please help me

xequte

38615 Posts

Posted - Aug 24 2016 :  16:45:42  Show Profile  Reply
Hi

Fastest would probably be to iterate through all the scanlines of the bitmap, incrementing the values of each of the relevant color variables.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

MMP112

Iran
3 Posts

Posted - Aug 26 2016 :  05:17:57  Show Profile  Reply
hi
thanks for the reply my problem .
me try to use scanlines for solve problems but i dont know how use this parameters for get color information.
please send to me a sample for solves problem.
thanks.
Go to Top of Page

xequte

38615 Posts

Posted - Aug 26 2016 :  21:02:46  Show Profile  Reply
Hi

What version of ImageEn are you using?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

MMP112

Iran
3 Posts

Posted - Aug 31 2016 :  04:09:39  Show Profile  Reply
hi
me use ImageEn 5.2 for delphi 7
Go to Top of Page

xequte

38615 Posts

Posted - Sep 01 2016 :  21:24:11  Show Profile  Reply
Here are some examples of working with TIEBitmap.Scanline:

// Convert image to gray-scale (PixelFormat must be ie24RGB)
// Same as TImageEnProc.ConvertToGray
var
  x, y: Integer;
  pPix: PRGB;
  Gray: Byte;
begin
  for y := 0 to ImageEnView1.IEBitmap.Height - 1 do
  begin
    pPix := ImageEnView1.IEBitmap.ScanLine[ y ];
    for x := 0 to ImageEnView1.SelectionMask.Width - 1 do
    begin
      Gray := (pPix^.R * IEGlobalSettings().RedToGrayCoef + pPix^.G * IEGlobalSettings().GreenToGrayCoef + pPix^.B * IEGlobalSettings().BlueToGrayCoef) div 100;
      pPix^.R := Gray;
      pPix^.G := Gray;
      pPix^.B := Gray;

      inc( pPix );
    end;
  end;
  ImageEnView1.Update();
end;


// Set all pixels within selection as red
// Same as ImageEnView1.SetSelectedPixelsColor
var
  x, y: Integer;
  pSel: pbyte;
  pPix: PRGB;
begin
  if ImageEnView1.SelectionMask.IsEmpty then
    raise Exception.create( 'Nothing selected' );

  if ImageEnView1.IEBitmap.PixelFormat <> ie24RGB then
    raise Exception.create( 'Not 24bit' );

  // Process selected area
  for y := 0 to ImageEnView1.SelectionMask.Height - 1 do
  begin
    pSel := ImageEnView1.SelectionMask.ScanLine[ y ];
    pPix := ImageEnView1.IEBitmap.ScanLine[ y ];

    case ImageEnView1.SelectionMask.BitsPerPixel of
      1:
        for x := 0 to ImageEnView1.SelectionMask.Width - 1 do
        begin
          // 1 Bit mask (values are 0 or 1)
          if (pbytearray(pSel)^[x shr 3] and iebitmask1[x and $7]) <> 0 then
          begin
            pPix^.R := 255;
            pPix^.G := 0;
            pPix^.B := 0;
          end;
          inc( pPix );
        end;
      8:
        for x := 0 to ImageEnView1.SelectionMask.Width - 1 do
        begin
          // 8 Bit mask (values are 0 to 255)
          if pSel^ <> 0 then
          begin
            pPix^.R := 255;
            pPix^.G := 0;
            pPix^.B := 0;
          end;
          inc( pSel );
          inc( pPix );
        end;
    end;
  end;
  ImageEnView1.Update();
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: