Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. Dim temp As Bitmap = PictureBox5.Image
  2. Dim raz As Integer = temp.Height / 3
  3. Dim height As Integer = temp.Height
  4. Dim width As Integer = temp.Width
  5. Dim rect As New Rectangle(Point.Empty, temp.Size)
  6. Dim bmpData As BitmapData = temp.LockBits(rect, ImageLockMode.[ReadOnly], temp.PixelFormat)
  7. Dim bpp As Integer = If((temp.PixelFormat = PixelFormat.Format32bppArgb), 2, 3)
  8. Dim size As Integer = bmpData.Stride * bmpData.Height
  9. Dim data As Byte() = New Byte(size - 1) {}
  10. System.Runtime.InteropServices.Marshal.Copy(bmpData.Scan0, data, 0, size)
  11. Dim options = New ParallelOptions()
  12. Dim maxCore As Integer = Environment.ProcessorCount - 1
  13. options.MaxDegreeOfParallelism = If(maxCore > 0, maxCore, 1)
  14. For y As Integer = 0 To height - 4
  15.  
  16. For x As Integer = 0 To width - 4
  17. If True Then
  18. Dim index As Integer = y * bmpData.Stride + x * bpp
  19. data(index) = Math.Min(Math.Abs(CInt(data(index)) - CInt(data(index + bpp + bmpData.Stride))) + 88, 255)
  20. data(index + 1) = Math.Min(Math.Abs(CInt(data(index + 1)) - CInt(data(index + bpp + 1 + bmpData.Stride))) + 88, 255)
  21. data(index + 2) = Math.Min(Math.Abs(CInt(data(index + 2)) - CInt(data(index + bpp + 2 + bmpData.Stride))) + 88, 255)
  22. End If
  23. Next
  24. Next
  25.  
  26. System.Runtime.InteropServices.Marshal.Copy(data, 0, bmpData.Scan0, data.Length)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement