Question Visual Basic - Emboss an Picturebox help

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

SteveIT3

Newbie
Jan 19, 2016
1
32
0
Basically I have two functions both emboss an image but the first is much to slow to use and the second runs great and fast but does not have the same effect as first . Can someone please help me make them alike.
C++:
picEmboss.SizeMode = PictureBoxSizeMode.StretchImage
        picEmboss.Size = New Size(100, 100)
        btnOk.Enabled = False
        chkStop.Focus()
        Dim bmap As New Bitmap(picEmboss.Image)
        picEmboss.Image = bmap
        'Needed variables
        Dim tempbmp As New Bitmap(picEmboss.Image)
        Dim i, j As Integer
        Dim DispX As Integer = 1, DispY As Integer = 1
        Dim red, green, blue As Integer
        Static former As Integer = 0 'first time it is run,its value is zero
        'So, we go across the image matrix, pixel by pixel
        Static Former_i As Integer = 0

        With tempbmp

            For i = Former_i To .Height - 2
                For j = 0 To .Width - 2
                    Dim pixel1, pixel2 As System.Drawing.Color
                    pixel1 = .GetPixel(j, i)
                    pixel2 = .GetPixel(j + DispX, i + DispY)
                    red = Math.Min(Math.Abs(CInt(pixel1.R) - CInt(pixel2.R)) + 128, 255)
                    green = Math.Min(Math.Abs(CInt(pixel1.G) - CInt(pixel2.G)) + 128, 255)
                    blue = Math.Min(Math.Abs(CInt(pixel1.B) - CInt(pixel2.B)) + 128, 255)
                    bmap.SetPixel(j, i, Color.FromArgb(red, green, blue))
                Next

            Next

        End With
Here is the second function that would like the same effect as the first on.
C++:
    Dim temp As Bitmap = PictureBox5.Image
                Dim raz As Integer = temp.Height / 3
                Dim height As Integer = temp.Height
                Dim width As Integer = temp.Width
                Dim rect As New Rectangle(Point.Empty, temp.Size)
                Dim bmpData As BitmapData = temp.LockBits(rect, ImageLockMode.[ReadOnly], temp.PixelFormat)
                Dim bpp As Integer = If((temp.PixelFormat = PixelFormat.Format32bppArgb), 2, 3)
                Dim size As Integer = bmpData.Stride * bmpData.Height
                Dim data As Byte() = New Byte(size - 1) {}
                System.Runtime.InteropServices.Marshal.Copy(bmpData.Scan0, data, 0, size)
                Dim options = New ParallelOptions()
                Dim maxCore As Integer = Environment.ProcessorCount - 1
                options.MaxDegreeOfParallelism = If(maxCore > 0, maxCore, 1)
                For y As Integer = 0 To height - 4
 
                    For x As Integer = 0 To width - 4
                        If True Then
                            Dim index As Integer = y * bmpData.Stride + x * bpp
                            data(index) = Math.Min(Math.Abs(CInt(data(index)) - CInt(data(index + bpp + bmpData.Stride))) + 128, 255)
                            data(index + 1) = Math.Min(Math.Abs(CInt(data(index + 1)) - CInt(data(index + bpp + 1 + bmpData.Stride))) + 128, 255)
                            data(index + 2) = Math.Min(Math.Abs(CInt(data(index + 2)) - CInt(data(index + bpp + 2 + bmpData.Stride))) + 128, 255)
                        End If
                    Next
                Next
 
                System.Runtime.InteropServices.Marshal.Copy(data, 0, bmpData.Scan0, data.Length)
All help is appreciated
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods