Advertisement
Brandan

Untitled

Aug 5th, 2014
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.13 KB | None | 0 0
  1.     Public Sub SaveBitmap2Level(ByVal filename As String, ByVal img As Bitmap)
  2.  
  3.         Dim converted As Bitmap = ResizeImage(img, New Size(128, 128))
  4.  
  5.         '  img.RotateFlip(RotateFlipType.Rotate90FlipXY)
  6.  
  7.         Dim MyLand As LandPoint() = New LandPoint(-1) {}
  8.         Dim writer As New BinaryWriter(File.Open(Populous.Populous.Info.InstallPath & filename, FileMode.Open))
  9.  
  10.         For x As Integer = 0 To converted.Width - 1
  11.             For y As Integer = 0 To converted.Height - 1
  12.  
  13.                 ' Save Land Height & Data
  14.                 If converted.GetPixel(x, y).R = 0 And converted.GetPixel(x, y).G > 0 And converted.GetPixel(x, y).B Then
  15.                     Dim landheight As UShort = Convert.ToInt16((255 - converted.GetPixel(x, y).G) * 4)
  16.                     writer.Write(landheight)
  17.                 ElseIf converted.GetPixel(x, y).R = 0 And converted.GetPixel(x, y).G = 0 And converted.GetPixel(x, y).B = 100 Then
  18.                     Dim landheight As UShort = Convert.ToInt16(0)
  19.                     writer.Write(landheight)
  20.                 End If
  21.  
  22.             Next
  23.         Next
  24.  
  25.         writer.Close()
  26.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement