JJ
2010-12-18 16:14:06 UTC
Hi,
I've been trying to find out what image format was loaded via
TPicture.LoadFromFile method. So far I found only two ways to do it:
1. Via TPicture.Graphic.ClassName. e.g.:
pic:= TPicture.Create;
pic.LoadFromFile(Edit1.Text);
if pic.Graphic.ClassName = 'TJPEGImage' then
begin
//process JPEG image
end;
2. Via TPicture.Graphic.ClassType. e.g.:
pic:= TPicture.Create;
pic.LoadFromFile(Edit1.Text);
if pic.Graphic.ClassType = TPNGImage then
begin
//process PNG image
end;
The first method is not so efficient since it's a string comparison.
Thus, it's slow and uh... lame. -_-
The second one is the one I'm currently using. It's much more efficient
and faster.
And so I was wondering if the second method is the most efficient one.
If there are more efficient or proper ways, please let me know.
Thanks in advance.
I've been trying to find out what image format was loaded via
TPicture.LoadFromFile method. So far I found only two ways to do it:
1. Via TPicture.Graphic.ClassName. e.g.:
pic:= TPicture.Create;
pic.LoadFromFile(Edit1.Text);
if pic.Graphic.ClassName = 'TJPEGImage' then
begin
//process JPEG image
end;
2. Via TPicture.Graphic.ClassType. e.g.:
pic:= TPicture.Create;
pic.LoadFromFile(Edit1.Text);
if pic.Graphic.ClassType = TPNGImage then
begin
//process PNG image
end;
The first method is not so efficient since it's a string comparison.
Thus, it's slow and uh... lame. -_-
The second one is the one I'm currently using. It's much more efficient
and faster.
And so I was wondering if the second method is the most efficient one.
If there are more efficient or proper ways, please let me know.
Thanks in advance.