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 

TImage sizesmaller than image

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





PostPosted: Fri Sep 08, 2006 8:10 am    Post subject: TImage sizesmaller than image Reply with quote



Hi again,

I am trying to view an image that is 3008x2000 pixels in size. Obviously,
this won't fit into the screen. I am holding the bitmap in a
Graphics::TBitMap which is big enough to fit the bitmap in question.
However, the TImage which will display this bitmap on screen is obviously
smaller than the size of the bitmap. How can I show this bitmap on a TImage,
with scrolling bars, so I could scroll through the entire image on screen.

--
Regards,
IraqiGeek
www.iraqigeek.com

The goal of the works of a genius' existance lies only in itself.
Back to top
Hans Galema
Guest





PostPosted: Fri Sep 08, 2006 4:00 pm    Post subject: Re: TImage sizesmaller than image Reply with quote



IraqiGeek wrote:

Quote:
I am trying to view an image that is 3008x2000 pixels in size. Obviously,
this won't fit into the screen.

Untested:

Put the TImage (Autosize == true) on a TScrollBox.

Hans.
Back to top
Hans Galema
Guest





PostPosted: Fri Sep 08, 2006 4:06 pm    Post subject: Re: TImage sizesmaller than image Reply with quote



Hans Galema wrote:

Quote:
Put the TImage (Autosize == true) on a TScrollBox.

A TScrollBox is not needed. Just put a TImage on a TForm
and set TImage::AutoSize to true;

Hans.
Back to top
IraqiGeek
Guest





PostPosted: Fri Sep 08, 2006 6:26 pm    Post subject: Re: TImage sizesmaller than image Reply with quote

Hans Galema wrote:
Quote:
Hans Galema wrote:

Put the TImage (Autosize == true) on a TScrollBox.

A TScrollBox is not needed. Just put a TImage on a TForm
and set TImage::AutoSize to true;

Hans.

Already did that before asking in the group, and it didn't work. I tried to
put the TImage inside a TScrollBox, but didn't know how to do that either.

--
Regards,
IraqiGeek
www.iraqigeek.com

Love may not make the world go round, but I must admit that it makes the
ride worthwhile.
Sean Connery
Back to top
JD
Guest





PostPosted: Fri Sep 08, 2006 9:35 pm    Post subject: Re: TImage sizesmaller than image Reply with quote

"IraqiGeek" <geek (AT) iraqigeek (DOT) com> wrote:
Quote:

I am trying to view an image that is 3008x2000 pixels in size.

Drop a TScrollBox on the form and set it's Align property to
alClient. Then drop a TPaintBox onto the TScrollBox. Set it's
Left and Top properties to 0,0.

Now, all that you need to do is size the TPaintBox to match
your TBitmap. So, when you know what it's Width and Height
are, set the TPaintBox's Width and Height accordingly.

The only other thing that you need to do is add an OnPaint event to the TPaintBox to copy the image of the bitmap to the screen which is one line of code:

PaintBox1->Canvas->CopyRect( Rect(0,0,Bmp->Width,Bmp->Height), Bmp->Canvas, Rect(0,0,Bmp->Width,Bmp->Height) );

You'll probably need some sort of checking to prevent an AV
because when the form is displayed, the OnPaint event will
fire and at that point the Bitmap probably won't be valid yet.
So, something like:

if( Bmp )
{
// paint it
}

~ JD
Back to top
IraqiGeek
Guest





PostPosted: Sat Sep 09, 2006 2:38 am    Post subject: Re: TImage sizesmaller than image Reply with quote

JD wrote:
Quote:
"IraqiGeek" <geek (AT) iraqigeek (DOT) com> wrote:

I am trying to view an image that is 3008x2000 pixels in size.

Drop a TScrollBox on the form and set it's Align property to
alClient. Then drop a TPaintBox onto the TScrollBox. Set it's
Left and Top properties to 0,0.

Now, all that you need to do is size the TPaintBox to match
your TBitmap. So, when you know what it's Width and Height
are, set the TPaintBox's Width and Height accordingly.

The only other thing that you need to do is add an OnPaint event to
the TPaintBox to copy the image of the bitmap to the screen which is
one line of code:

PaintBox1->Canvas->CopyRect( Rect(0,0,Bmp->Width,Bmp->Height),
Bmp->Canvas, Rect(0,0,Bmp->Width,Bmp->Height) );

You'll probably need some sort of checking to prevent an AV
because when the form is displayed, the OnPaint event will
fire and at that point the Bitmap probably won't be valid yet.
So, something like:

if( Bmp )
{
// paint it
}

~ JD

Thanks again JD. I got the bitmap inside the scroll box, but when I scroll
in either direction, the image isnt redrawn. I tried using
TPaintBox->Refresh() being called from TFrom::FormPaint, but it didn't work,
and brought the system to its knees.

--
Regards,
IraqiGeek
www.iraqigeek.com

The wise man learns more from his enemies than a fool does from his friends.
Chinese Proverb
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Sep 09, 2006 4:11 am    Post subject: Re: TImage sizesmaller than image Reply with quote

"IraqiGeek" <geek (AT) iraqigeek (DOT) com> wrote in message
news:45011aef (AT) newsgroups (DOT) borland.com...

Quote:
How can I show this bitmap on a TImage, with scrolling bars,
so I could scroll through the entire image on screen.

Put the TImage onto a TScrollBox that has its AutoScroll and AutoSize
properties set to true. After loading the TImage, you can then assign the
image's Width and Height values to the TScrollBox's HorzScrollBar->Range and
VertScrollBar->Range properties, respectively


Gambit
Back to top
IraqiGeek
Guest





PostPosted: Sat Sep 09, 2006 6:27 am    Post subject: Re: TImage sizesmaller than image Reply with quote

Remy Lebeau (TeamB) wrote:
Quote:
"IraqiGeek" <geek (AT) iraqigeek (DOT) com> wrote in message
news:45011aef (AT) newsgroups (DOT) borland.com...

How can I show this bitmap on a TImage, with scrolling bars,
so I could scroll through the entire image on screen.

Put the TImage onto a TScrollBox that has its AutoScroll and AutoSize
properties set to true. After loading the TImage, you can then
assign the image's Width and Height values to the TScrollBox's
HorzScrollBar->Range and VertScrollBar->Range properties, respectively


Gambit

Thanks Remy, this is exactly what I was looking for. It works beautifully.

--
Regards,
IraqiGeek
www.iraqigeek.com

To err is human; to really foul things up requires a computer.
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.