smallbasic

how do I display a row of images that are of different sizes without overlapping?


I want a small basic program that can display multiple images in a row without overlapping. But since not all image files are the same, it's hard to do so.

dir = Program.Directory
imagedir = dir + "\images\"
GraphicsWindow.BrushColor = "White"
For i = 1 To 27
  i_name= File.ReadLine(imagedir+"\imagedata.txt",b) 'imagedata contains the names of all the images in the directory so I don't have to list all the names in the program.
  image[i] = ImageList.LoadImage(imagedir+i_name+".png")
  imagewidth[i] = ImageList.GetWidthOfImage(image[i])
  GraphicsWindow.DrawImage(block[i],(i-1)*imagewidth[i-1],0) 'This is where the trouble lies.
EndFor

Solution

  • I think you'd need another variable for storing the x coordinate. Every time you draw an image, you should increase the variable by its width plus the margin. Then, when you draw the next image, draw it at the position indicated by the variable.