Picture.IndexedImage

From Xojo Documentation
Jump to: navigation, search
Property (As Picture)
The property is read-only.

PictureValue = aPicture.IndexedImage(Index as Integer)

Returns the image in the picture specified by the passed Index (0-based).

Example

This example gets the image referenced by the passed index and displays it in the ImageWell.

Dim pic As Picture
Dim f As FolderItem
f = GetOpenFolderItem("image/jpeg")
If f <> Nil Then
pic = Picture.Open(f)
ImageWell1.Image = pic.IndexedImage(1)
End If


If you have an Image Set with multiple images for HiDPI and want to split out each of the pictures it contains, you can do so like this:

Dim g As Graphics
Dim p, pics() As Picture

' Break the Image into its component pictures
' Also copy the horizontal/vertical resolution and scale factors
' so that the pictures draw properly when used later.
For i As Integer = 0 To MyImageSet.ImageCount - 1
p = New Picture(MyImageSet.IndexedImage(i).Width, MyImageSet.IndexedImage(i).Height)
p.HorizontalResolution = MyImageSet.IndexedImage(i).HorizontalResolution
p.VerticalResolution = MyImageSet.IndexedImage(i).VerticalResolution
pics.Append(p)
g = p.Graphics
g.ScaleX = p.HorizontalResolution / 72
g.ScaleY = p.VerticalResolution / 72
g.DrawPicture(MyImageSet.IndexedImage(i), 0, 0)
Next

If you later modify the pictures in the array and want to recreate it as an image, you can do so using the constructor like this:

' Recreate the image from the component pictures
p = New Picture(MyImageSet.Width, MyImageSet.Height, pics)
Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About