Dim igPage As ImGearPage
'Load an image into a ImGearPage object
Dim localFile As FileStream = New FileStream(localFilePath, FileMode.Open)
Try
igPage = ImGearFileFormats.LoadPage(localFile, 0)
Finally
localFile.Close()
End Try
'Get the upper left square of the image to perform a transpose on.
Dim transposeSize As Integer
If (igPage.DIB.Height > igPage.DIB.Width) Then
transposeSize = igPage.DIB.Width / 2
Else
transposeSize = igPage.DIB.Height / 2
End If
Dim igPixelArray As ImGearPixelArray = igPage.DIB.GetAreaCopy(0, 0, transposeSize - 1, transposeSize - 1)
'Transpose the pixels in igPixelArray
Dim channelData, transposePosition1, transposePosition2 As Integer
For row As Integer = 1 To transposeSize - 1
For column As Integer = 0 To row - 1
transposePosition1 = (row * transposeSize) + column
transposePosition2 = (column * transposeSize) + row
For channel As Integer = 0 To igPixelArray.ChannelCount - 1
channelData = igPixelArray(transposePosition1, channel)
igPixelArray(transposePosition1, channel) = igPixelArray(transposePosition2, channel)
igPixelArray(transposePosition2, channel) = channelData
Next
Next
Next
'Update the original image with the transposed array
igPage.DIB.UpdateAreaFrom(0, 0, transposeSize - 1, transposeSize - 1, igPixelArray)