BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TJPEGImage Scaling?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
Martin Fensome
Guest





PostPosted: Sat Jan 22, 2005 3:21 am    Post subject: TJPEGImage Scaling? Reply with quote



I posted about this years ago Sad when I was playing around...never did
find out why it didn't work.
But it wasn't something I "needed" to do...and I've started playing again
and thought that I would like to find out why.

Can anyone offer any hints as to why the image is not scaled when
displayed?

I have a TImage component on the form.
I've iterated through changing all the settings - stretch, center, autosize.
But none are affecting the Scale property.
I've included jpeg.hpp. I'm using BCB 5 Pro with update 1 installed.


I'm assuming I'm doing something very stupid/obvious...but can't figure it
out.

Thanks in advance,

PS - This code does compile and display the image, it just doesn't scale it
to 1/8 the size or any size other than the timage size or full size.


Martin

void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
TJPEGImage *JImage = new TJPEGImage;

JImage->ProgressiveDisplay = true;
JImage->Scale = TJPEGScale(jsEighth);

JImage->LoadFromFile( "D:\Data\Pictures\P1030150.JPG" );

JImage->ProgressiveDisplay = false;
JImage->Scale = TJPEGScale(jsEighth);

Image1->Picture->Assign(JImage);

delete JImage;
}


Back to top
Hans Galema
Guest





PostPosted: Sat Jan 22, 2005 1:46 pm    Post subject: Re: TJPEGImage Scaling? Reply with quote



Martin Fensome wrote:

Quote:
I have a TImage component on the form.
I've iterated through changing all the settings - stretch, center, autosize.
But none are affecting the Scale property.

Scale is a property of TJPEGImage. Not of TImage.

You apply a Scale to the jpg and then assign it to TImage. If it
does not scale then TJPEGImage fails.

Indeed the Scale does not work as you and I think but Width and
Height of the TJPEGImage are changed.

Reading the help Scale is used to make the loadtime less.

Are you interested in the load time or just to display the jpg
in 1/8 of the size ?

If the latter you just have two options. With
the second you do not need to Scale.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
TJPEGImage *JPEGImage = new TJPEGImage;

JPEGImage->Scale = TJPEGScale(jsEighth);

JPEGImage->LoadFromFile( ........ );

Image1->Width = JPEGImage->Width ;
Image1->Height = JPEGImage->Height;

Image1->Stretch = true;

Image1->Picture->Assign(JPEGImage);

delete JPEGImage;
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
TJPEGImage *JPEGImage = new TJPEGImage;

JPEGImage->LoadFromFile( ........ );

Image1->Width = JPEGImage->Width / 8 ;
Image1->Height = JPEGImage->Height/ 8;

Image1->Stretch = true;

Image1->Picture->Assign(JPEGImage);

delete JPEGImage;
}

Hans.

Back to top
Martin Fensome
Guest





PostPosted: Sun Jan 23, 2005 8:45 pm    Post subject: Re: TJPEGImage Scaling? Reply with quote



"Hans Galema" <notused (AT) notused (DOT) nl> wrote


Hans, thank you for your response.

I'm still curious why the Scale property doesn't appear to work like in a
jpeg demo I downloaded?

They don't do any division of width, they just set scale to jsHalf or
whatever, and the picture is scaled by the JPG class.

I think it's an old demo form borland...here is the code for the Scale combo
box change event:

I've commented above the line where they use scale that doesn't do anything
in my code.

oid __fastcall TForm1::SetJPEGOptions(TObject *Sender){
TJPEGImage *jpegimage = dynamic_cast<TJPEGImage
*>(Image1->Picture->Graphic);
if (jpegimage){
jpegimage->PixelFormat = TJPEGPixelFormat(PixelFormat->ItemIndex);

// below line seems to be the only thing that they are changing relative to
the size of the picture
jpegimage->Scale = TJPEGScale(Scale->ItemIndex);

jpegimage->Grayscale = bool(ColorSpace->ItemIndex);
jpegimage->Performance = TJPEGPerformance(Performance->ItemIndex);
jpegimage->ProgressiveDisplay = ProgressiveDisplay->Checked;

Scale->Enabled = true;
PixelFormat->Enabled = true;
ColorSpace->Enabled = true;
Performance->Enabled = true;
ProgressiveDisplay->Enabled = jpegimage->ProgressiveEncoding;
Image1->IncrementalDisplay = IncrementalDisplay->Checked;
}
}


Thanks again

Martin


Back to top
Martin Fensome
Guest





PostPosted: Tue Jan 25, 2005 3:12 am    Post subject: Re: TJPEGImage Scaling? Reply with quote

"Hans Galema" <notused (AT) notused (DOT) nl> wrote


Hans, thank you for your response.

I'm still curious why the Scale property doesn't appear to work like in a
jpeg demo I downloaded (I think from Borland)?


They don't do any division of width in the code, they just set scale to
jsHalf or
whatever, and the picture is scaled by the JPG class itself (apparently).

I think it's an old demo form borland...here is the code for the Scale combo
box change event:

I've commented above the line where they use scale property that doesn't do
anything
in my code.

oid __fastcall TForm1::SetJPEGOptions(TObject *Sender){
TJPEGImage *jpegimage = dynamic_cast<TJPEGImage
*>(Image1->Picture->Graphic);
if (jpegimage){
jpegimage->PixelFormat = TJPEGPixelFormat(PixelFormat->ItemIndex);

// below line seems to be the only thing that they are changing relative to
the size of the picture
jpegimage->Scale = TJPEGScale(Scale->ItemIndex);

jpegimage->Grayscale = bool(ColorSpace->ItemIndex);
jpegimage->Performance = TJPEGPerformance(Performance->ItemIndex);
jpegimage->ProgressiveDisplay = ProgressiveDisplay->Checked;

Scale->Enabled = true;
PixelFormat->Enabled = true;
ColorSpace->Enabled = true;
Performance->Enabled = true;
ProgressiveDisplay->Enabled = jpegimage->ProgressiveEncoding;
Image1->IncrementalDisplay = IncrementalDisplay->Checked;
}
}


Thanks again

Martin



Back to top
Hans Galema
Guest





PostPosted: Tue Jan 25, 2005 12:37 pm    Post subject: Re: TJPEGImage Scaling? Reply with quote

Martin Fensome wrote:

Quote:
I'm still curious why the Scale property doesn't appear to work like in a
jpeg demo I downloaded (I think from Borland)?

I think it's an old demo form borland...here is the code for the Scale combo
box change event:

Well it is unclear for me if that code works if you use it in
your own project.

Please inform me first.

Hans.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.