Solved

Get pixel color of a jpg in a TImage

Posted on 2013-11-07
1
2,882 Views
Last Modified: 2013-11-19
Hi Experts,

I need to get the pixel color of a jpg image inside of TImage. How can I do this ?

Something like this:

var
  pixel_color    : TColor;
begin
  pixel_color := Image1.Canvas.Pixels[0, 0];
end;

But this code only works to BMP image.

I am using Delphi Xe4

Thanks for some help
Alexandre
0
Comment
Question by:alpires
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 39632236
Here is small example:
var
  jpeg: TJPEGImage;
  bmp: Tbitmap;
begin
  jpeg := TJPEGImage.Create;
  try
    jpeg.LoadFromFile('c:\test.jpg');
    bmp := Tbitmap.Create;
    try
      bmp.PixelFormat := pf24bit;
      bmp.Width := jpeg.Width;
      bmp.Height:= jpeg.Height;
      bmp.Assign(jpeg);
      //access pixel
      ShowMessage(IntToHex(Cardinal(bmp.Canvas.Pixels[1, 1]), 8));
    finally
      bmp.Free;
    end;
  finally
    jpeg.Free;
  end;

Open in new window

0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question