Fast picture rendering by robomatics


SUBMITTED BY: Guest

DATE: Aug. 31, 2014, 2:49 p.m.

FORMAT: Text only

SIZE: 1.3 kB

HITS: 591

  1. Dim BMP As Bitmap
  2. Dim x,y as Integer
  3. Dim rect As New Rectangle(0, 0, x, y)
  4. Dim bmpData As System.Drawing.Imaging.BitmapData = BMP.LockBits(rect, Drawing.Imaging.ImageLockMode.ReadWrite, BMP.PixelFormat)
  5. Dim ptr As IntPtr = bmpData.Scan0
  6. Dim bytes As Integer = bmpData.Stride * y
  7. Dim rgbValues(bytes - 1) As Byte
  8. System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes)
  9. Dim secondcounter As Integer = 0
  10. Dim tempred As Integer
  11. Dim tempblue As Integer
  12. Dim tempgreen As Integer
  13. Dim tempalpha As Integer
  14. Dim tempx As Integer
  15. Dim tempy As Integer
  16. While secondcounter < rgbValues.Length
  17. tempblue = rgbValues(secondcounter)
  18. tempgreen = rgbValues(secondcounter + 1)
  19. tempred = rgbValues(secondcounter + 2)
  20. tempalpha = rgbValues(secondcounter + 3)
  21. tempalpha = 255
  22. tempy = ((secondcounter * 0.25) / x)
  23. tempx = (secondcounter * 0.25) - (tempy * x)
  24. If tempx < 0 Then
  25. tempx = tempx + x
  26. End If
  27. 'Code
  28. rgbValues(secondcounter) = tempblue
  29. rgbValues(secondcounter + 1) = tempgreen
  30. rgbValues(secondcounter + 2) = tempred
  31. rgbValues(secondcounter + 3) = tempalpha
  32. secondcounter = secondcounter + 4
  33. End While
  34. System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes)
  35. BMP.UnlockBits(bmpData)

comments powered by Disqus