Solved

Get pixel color of a jpg in a TImage

Posted on 2013-11-07
1
2,649 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
1 Comment
 
LVL 26

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to renew a Delphi rad-studio licence? 5 65
TEMBEDDEDWB how can i change its user agent ? 8 58
how can i search if string exist in array ? 3 58
Message not shown 5 50
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

773 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