Board index » delphi » Thumbnail image of many graphic files...

Thumbnail image of many graphic files...

// This code was typed directly
// into the news reader, so it
// probably contains errors.

  var
    FormX, FormY : integer;
    i : integer;
    NumOfImagesX, NumOfImagesY : integer;
    NumberOfImages : integer;

  // Assuming each image has a
  // width of 20...
  const
    IMAGE_WIDTH : integer = 20;
begin
  // Get the area the images will
  // have to fit in.
  FormX := Form1.Width;
  FormY := Form1.Height;

  // Get the number of images that will
  // fit in each row.
  NumOfImagesX := trunc(IMAGE_WIDTH/FormX);

  // Get the number of images that will
  // fit in each column.
  NumberOfImagesY := trunc(IMAGE_WIDTH/FormY);

  // Get the total number of images that will
  // fit in the given area.
  NumberOfImages := (NumberOfImagesX * NumberOfImagesY);
end;

--
-Capitalist
------------------------
Don't email me unless I ask you to.
Go shopping for *any thing* at http://delphi.bigsmart.com

...

Quote
A programmer <YnospamXprogram...@YnospamXtechie.com> wrote in message

news:h63jhssbsgt7mbg7saheoqq9vb1sm3nngi@4ax.com...
Quote
> Hi, does anyone know how to calculate the number of images that can
> fit in an area?

> Say, 800x600, and I have, say, 49, images, how to calculate what's
> the "optimal" number of images to display per row? The images will ,
> needless to say, be stretched.

> Is there a given formula that can, like, calculate, something for
the
> above? Or, say, calculate what is the height and width for each
image?

> Something like,

>  SingleWidth := NumberOfImages div XX;
>  SingleHeight := NumberOfImages div YY;

> where in this case, NumberOfImages is 49.

 

Re:Thumbnail image of many graphic files...


Hi, does anyone know how to calculate the number of images that can
fit in an area?

Say, 800x600, and I have, say, 49, images, how to calculate what's
the "optimal" number of images to display per row? The images will ,
needless to say, be stretched.

Is there a given formula that can, like, calculate, something for the
above? Or, say, calculate what is the height and width for each image?
Something like,

 SingleWidth := NumberOfImages div XX;
 SingleHeight := NumberOfImages div YY;

where in this case, NumberOfImages is 49.

Re:Thumbnail image of many graphic files...


On Wed, 10 May 2000 13:31:01 -0400, "Capitalist" <ji...@aps-soft.com>
wrote:

Quote
>  // Get the number of images that will
>  // fit in each row.
>  NumOfImagesX := trunc(IMAGE_WIDTH/FormX);

>  // Get the number of images that will
>  // fit in each column.
>  NumberOfImagesY := trunc(IMAGE_WIDTH/FormY);

Your code bears the assumption that the image is a square.
What if it's not?

Re:Thumbnail image of many graphic files...


Quote
A programmer wrote:

<Sniped>

Hi,

It depends what you are after are all the images going to have the same
size not square but the same e.g. all your images will have a size of
320x200 pixels or are you going to show the pictures with different sizes?
if the first are you going to auto rotate the images to fit more on the
screen or are you going to show them as they are. Well lets suppose that
you do have the same size in all your images you want do any rotation and
you want all the images to be included in the screen then what you really
do is the following

 a:= imagesizeX / imagesizeY
b:= ScreenSizeX / ScreenSizeY
final := a/b;
ImagesInX:=ScreenSizeX Div Final
ImagesInY:=ScreensizeY div Final.

The above is not accurate don't recall the exact algorithm I haven't done
it for for a while and I don't have any examples with me (recently changed
Job).You can download my thumbnails component from torry and have a look
on it to see what I have done

Hope it gives you a starting place.

Best regards
Johnnie.

Other Threads