Open a PNG file?
My hope is to start with a PNG file on storage, then open it into an app as a picture and to then extract the pixels from the picture. I have tried the following function:
Dim picFile As FolderItem
Dim clr as Color
Dim pic As Picture
Dim c, r, pwd, pht as integer
Dim pngType As New FileType
pngType.Name = “image/png”
pngType.MacType = “PNGf”
pngType.MacCreator=“ogle”
pngType.Extensions = “.png”
picFile = GetOpenFolderItem(pngType)
If picFile <> Nil Then
pic = Picture.Open(picFile)
pwd = pic.Width
pht = pic.Height
ReDim mypixels(pwd, pht) // mypixels is global
dim rs as RGBSurface = pic.RGBSurface
for c = 0 to pwd - 1
for r = 0 to pht - 1
mypixels(c, r) = rs.pixel(c, r)
next
next
End If
Return True
What happens: When mypixels are drawn only the upper left quarter of the PNG appears. And pic has a nil Graphics property (so no Graphics.pixel).