Article View: borland.public.cppbuilder.multimedia
Article #437JPEG properties
From: Colin B Maharaj
Date: Mon, 09 Aug 2004 11:28
Date: Mon, 09 Aug 2004 11:28
43 lines
2612 bytes
2612 bytes
Hi all, is there anyway to get the dimensions of a jpeg without opening
it and loading it into a Bitmap memory block. The code snippet here
creates a wrapper for jpegs whose file names are in a string list, if I
have 30 jpegs does it mean I load all these jpegs one by one? Is there a
way I can read the header and get the dimensions? This way I do not take
up much resources?
AnsiString MakeJPEGHtmlWrapper(TStringList * L)
{
AnsiString A = "<html>\r\n<head>\r\n</head><body><br>\r\n";
A += "<";
A += "table style=\"width: 100%; text-align: left;\"";
A += "border=\"0\"";
A += "cellpadding=\"2\"";
A += "cellspacing=\"2\"";
A += "<tbody>";
TJPEGImage *jpg = new TJPEGImage;
Graphics::TBitmap *bmp = new Graphics::TBitmap;
for (int i=0; i<L->Count; i++)
{
AnsiString B = L->Strings[i];
while (B.Length() && B.Pos("\\")>0) B.Delete(1, 1);
if (FileExists(B)==true)
{
A += "\r\n<tr>\r\n";
A += " <td style=\"vertical-align: top;\"><img title=\"";
A += (AnsiString) "Image " + IntToStr(i+1) + "\"";
A += (AnsiString) "src=\"";
A += B; A += "\"";
A += (AnsiString) " alt=\"\" ";
A += (AnsiString) " style=\"";
jpg->LoadFromFile(B); // does this take up much resources??
bmp->Assign(jpg);
A += (AnsiString) "width: " + IntToStr(bmp->Width)+"px\; " +
"height: " + IntToStr(bmp->Height)+"px\; \">";
A += " </td>\r\n </tr>\r\n ";
}
}
A += " </tbody>\r\n </table>\r\n ";
A += " </body>\r\n </html>\r\n ";
delete jpg;
return A;
}
Technical Details
Message-ID:
<41175fe0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!wn13feed!worldnet.att.net!216.196.98.144!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,6720cf3f1348e602,start X-Google-Attributes: gid10d0fc,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 09 Aug 2004 07:28:19 -0400 From: Colin B Maharaj <noreply@myhost.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040219 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.multimedia Subject: JPEG properties Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 200.108.15.154 Message-ID: <41175fe0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1092050912 200.108.15.154 (9 Aug 2004 04:28:32 -0700) Lines: 43 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!wn13feed!worldnet.att.net!216.196.98.144!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail