| View previous topic :: View next topic |
| Author |
Message |
Martin Fensome Guest
|
Posted: Sat Jan 22, 2005 3:21 am Post subject: TJPEGImage Scaling? |
|
|
I posted about this years ago 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
|
Posted: Sat Jan 22, 2005 1:46 pm Post subject: Re: TJPEGImage Scaling? |
|
|
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
|
Posted: Sun Jan 23, 2005 8:45 pm Post subject: Re: TJPEGImage Scaling? |
|
|
"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
|
Posted: Tue Jan 25, 2005 3:12 am Post subject: Re: TJPEGImage Scaling? |
|
|
"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
|
Posted: Tue Jan 25, 2005 12:37 pm Post subject: Re: TJPEGImage Scaling? |
|
|
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 |
|
 |
|