Board index » cppbuilder » jpeglib

jpeglib


2006-04-23 07:35:46 AM
cppbuilder53
Hi!
Im trying to include the JPEGLib 6b.
I tried to include the "jpeglib.h" but Im getting a lot of errors.
Is there a way to include the jpeglib.lib Library directly?
Does anyone know some examples for c++ Builder and the JPEGLib Library?
Is the JPEGLib Library Thread-Safe?
Thanks
Johannes
 
 

Re:jpeglib

newsgroup.borland.com wrote:
Quote
Im trying to include the JPEGLib 6b.
Try this:
#include <jpeg.hpp>
Hans.
 

Re:jpeglib

Hi!
Is the TJPEGImage Thread-Safe? I think it is not.
I used the TJPEGImage in seperated "TThreads" in my App. to create
thumbnails.
Result: "1000s correct thumbnails and some empty thumbnails". (some "clear
white" thumbs);
Here i a piece of code which runs inside the thread:
int CreateThumbnailFromJPEGFileAndSaveToJPEGStream(AnsiString
Filename,TStream *DestStream,int ThumbWidth,int ThumbHeight,signed char
Quality)
{
int r=0;
TFileStream *FileStream;
try
{
FileStream=new TFileStream(Filename,fmOpenRead | fmShareDenyWrite);
if (FileStream==NULL) return 2;
Graphics::TBitmap *bitmap=new Graphics::TBitmap();
TJPEGImage *image=new TJPEGImage();
image->Performance=jpBestSpeed;
int nw,nh;
try
{
image->LoadFromStream(FileStream);
image->Scale=GetJPEGScaleANDNewDimensions(image->Width,image->Height,ThumbWidth,ThumbHeight,nw,nh);
bitmap->Width=nw; bitmap->Height=nh;
TRect Rect; Rect.Left=0; Rect.Top=0; Rect.Right=nw; Rect.Bottom=nh;
bitmap->Canvas->StretchDraw(Rect,image);
image->Smoothing=true;
image->Assign(bitmap);
image->CompressionQuality=Quality;
image->SaveToStream(DestStream);
}
catch(...)
{
r=1;
}
delete bitmap;
delete image;
delete FileStream;
}
catch(...)
{
r=3;
}
return r;
}
TJPEGScale GetJPEGScaleANDNewDimensions(int Width,int Height,int
MaxWidth,int MaxHeight,int & NewWidth,int & NewHeight)
{
float v1=(float)MaxWidth/float(MaxHeight);
float v2=(float)Width/(float)Height;
if (v2>v1)
{
NewWidth=MaxWidth;
NewHeight=(int)((MaxWidth*Height)/Width);
} else
{
NewHeight=MaxHeight;
NewWidth=(int)((MaxHeight*Width)/Height);
}
float scale=(float)Width/(float)NewWidth;
if (scale<2) return jsFullSize;
if (scale<4) return jsHalf;
if (scale<8) return jsQuarter;
return jsEighth;
}
"Hans Galema" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
newsgroup.borland.com wrote:

>Im trying to include the JPEGLib 6b.

Try this:

#include <jpeg.hpp>

Hans.
 

{smallsort}

Re:jpeglib

newsgroup.borland.com wrote:
Quote
Im trying to include the JPEGLib 6b.

I tried to include the "jpeglib.h" but Im getting a lot of errors.
Is there a way to include the jpeglib.lib Library directly?
Does anyone know some examples for c++ Builder and the JPEGLib Library?
Years ago, Harold Howe wrote an article for his web site about compiling
the library with the Borland Free Commandline tool (BCC 5.5).
Unfortunately the site doesn't exist anymore but you can find a copy of
this article here:
web.archive.org/web/20041017012829/www.bcbdev.com/articles/jpeg.htm
Alternatively, you can download a zip file containing the entire site
and therefore the aforementioned article here:
www.leunen.com/download/bcbDevFaqs.zip
Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------
 

Re:jpeglib

newsgroup.borland.com wrote:
Quote
Is the TJPEGImage Thread-Safe? I think it is not.
Don't know.
Quote
I used the TJPEGImage in seperated "TThreads" in my App. to create
thumbnails.
Result: "1000s correct thumbnails and some empty thumbnails". (some "clear
white" thumbs);
The original file is ok ?
Quote
Here i a piece of code which runs inside the thread:
That looks ok to me.
But why using an intermediate TFileStream where you can load the file directly:
image->LoadFromFile(FileName);
Quote
FileStream=new TFileStream(Filename,fmOpenRead | fmShareDenyWrite);
if (FileStream==NULL) return 2;
If the file can not be opened, TFileStream throws an exception. So you
have to catch there. But better omit all and use
FileExists() to check existence.
Hans.
 

Re:jpeglib

Hi!
Thanks for your quick answer.
All files are ok,exist and are not accessed by any other app - 100%
Thanks
Johannes
"Hans Galema" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
newsgroup.borland.com wrote:

>Is the TJPEGImage Thread-Safe? I think it is not.

Don't know.

>I used the TJPEGImage in seperated "TThreads" in my App. to create
>thumbnails.
>Result: "1000s correct thumbnails and some empty thumbnails". (some
>"clear white" thumbs);

The original file is ok ?

>Here i a piece of code which runs inside the thread:

That looks ok to me.

But why using an intermediate TFileStream where you can load the file
directly:

image->LoadFromFile(FileName);

>FileStream=new TFileStream(Filename,fmOpenRead | fmShareDenyWrite);
>if (FileStream==NULL) return 2;

If the file can not be opened, TFileStream throws an exception. So you
have to catch there. But better omit all and use
FileExists() to check existence.

Hans.

 

Re:jpeglib

"newsgroup.borland.com" < XXXX@XXXXX.COM >wrote in message
Quote
I tried to include the "jpeglib.h" but Im getting a lot of errors.
For future reference, next time you say that you have errors, please specify
what the errors actually are, and show the code that is reporting them.
Gambit