Board index » delphi » View and scroll jpg pictures in TImage

View and scroll jpg pictures in TImage

How can I load a .jpg bitmap in a Image component and, when the picture
doesn't fit, scroll to the right or left???
How can shape-components be placed under that .jpg-picture to give the
ability to click with the mouse at a part of the picture and move at the
right position while scrolling???    

please help me...

tp

 

Re:View and scroll jpg pictures in TImage


Quote
> How can I load a .jpg bitmap in a Image component and, when the picture
> doesn't fit, scroll to the right or left???

If you're using D3, on the CD in INFO\EXTRAS directory there's a JPEG
component you can use. This enables TImage to display JPEG images as it
would do with a BMP. Of course, there are a number of free TImage
components too. You'll have to look around. Here's how to install the
JPEG component from the CD: (instructions from web, author unknown?)

Step 1 - Copying the JPEG files to your hard drive

  Insert your Delphi 3 CD in your CD-ROM drive.
  In the Explorer, browse to the INFO\EXTRAS directory.
  To copy the JPEG folder, drag and drop it from the Explorer to
  another folder, e.g. C:\MyStuff.
  All the JPEG files should now be in C:\MyStuff\JPEG.
  To make thing easier for us, now copy all the files from the
  C:\MyStuff\JPEG\OBJ folder to the C:\MyStuff\JPEG folder.
  Do this by, in the Explorer, selecting all the files in the
  C:\MyStuff\JPEG\OBJ. When all files are selected, right click
  and choose Copy. Then browse to C:\MyStuff\JPEG and choose
  Paste.

Step 2 - Installing the JPEG components

  Launch Delphi 3.0
  From Delphi's main menu, select Component | Install Component
  You'll should now see the "Install Component" dialog.
  Hit the Browse button next to the Unit file name box.
  In the "Unit file name" dialog, browse to C:\MyStuff\JPEG.
  Select the file named JPEG.PAS and hit Open.
  The Unit file name box should now be filled in properly.
  Make sure the Package file name is set to the Delphi User's
  Components package, which by default is in this location:
    C:\Program Files\Borland\Delphi 3\Lib\dclusr30.dpk
  Hit OK.
  You'll now see a "Confirm" dialog, saying that the package
  will be installed.
  Hit Yes.
  You should now see an "Information" dialog, saying that the
  package is installed.
  Exit the package editor and make sure you save the changes
  to the package.

Step 3 - Using the JPEG component

  Simply drop down a TImage and load a JPEG into the Picture
  property. Also, make sure the JPEG unit is in the USES clause,
  so that the JPEG stuff is registered at run-time.

Now to the second part of you question, regarding scrolling. Delphi
makes this very easy. Just use a TScrollBox and place the TImage in the
scrollbox. Be sure to set the autosize property to True for the image.
It depends how fancy you want your app to be, but you can write a few
lines of code to center the image within the scrollbox. This makes your
app nicer looking. Use the ClientHeight/Width of the scrollbox and DIV
them by the size of the image. I've done the same thing and also made a
little 10 pixel offset from the inner edges of the scroll box so the
image isn't right up against the edges of the scrollbox. This adds a
nice touch.

Quote
> How can shape-components be placed under that .jpg-picture to give the
> ability to click with the mouse at a part of the picture and move at the
> right position while scrolling???

I don't understand what you what to do here?

-Robert

Other Threads