Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub SaveBitmap2Level(ByVal filename As String, ByVal img As Bitmap)
- Dim converted As Bitmap = ResizeImage(img, New Size(128, 128))
- ' img.RotateFlip(RotateFlipType.Rotate90FlipXY)
- Dim MyLand As LandPoint() = New LandPoint(-1) {}
- Dim writer As New BinaryWriter(File.Open(Populous.Populous.Info.InstallPath & filename, FileMode.Open))
- For x As Integer = 0 To converted.Width - 1
- For y As Integer = 0 To converted.Height - 1
- ' Save Land Height & Data
- If converted.GetPixel(x, y).R = 0 And converted.GetPixel(x, y).G > 0 And converted.GetPixel(x, y).B Then
- Dim landheight As UShort = Convert.ToInt16((255 - converted.GetPixel(x, y).G) * 4)
- writer.Write(landheight)
- ElseIf converted.GetPixel(x, y).R = 0 And converted.GetPixel(x, y).G = 0 And converted.GetPixel(x, y).B = 100 Then
- Dim landheight As UShort = Convert.ToInt16(0)
- writer.Write(landheight)
- End If
- Next
- Next
- writer.Close()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement