Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I'm Nicho, I wanna ask you how to use "pointer" in vb.net I was translete code from c# that used a pointer to VB/net
 
here is the code
 
private void btBrowseCoverHistogram_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < 256; i++)
        {
            LabelCover[i] = i;
            LumCover[i] = 0;
            RedCover[i] = 0;
            GreenCover[i] = 0;
            BlueCover[i] = 0;
 
        }
        String citracoverhistogram = GetCitraCover("JPEG (*.jpg)|*.jpg|Bitmaps (*.bmp)|*.bmp");
        if (citracoverhistogram != null)
        {
            txtCitraCoverHistogram.Text = citracoverhistogram;
            AturCitraCover(citracoverhistogram);
            this.Cursor = Cursors.WaitCursor;
 
            try
            {
                Bitmap citracover = new Bitmap(citracoverhistogram);
                BitmapData data = citracover.LockBits(new System.Drawing.Rectangle(0, 0, citracover.Width, citracover.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
 
                unsafe
                {
                    byte* pointer = (byte*)data.Scan0;
 
                    int sisa = data.Stride - data.Width * 3;
 

 
                    for (int i = 0; i < data.Height; i++)
                    {
 
                        for (int j = 0; j < data.Width; j++)
                        {
 
                            int ratarata = (int)(0.114 * pointer[0] + 0.587 * pointer[1] + 0.299 * pointer[2]);
                            int red = pointer[2];
                            int green = pointer[1];
                            int blue = pointer[0];
                            //
                            LumCover[ratarata]++;
                            RedCover[red]++;
                            GreenCover[green]++;
                            BlueCover[blue]++;
                            //
                            pointer += 3;
                        }
                        pointer += sisa;
                    }
                }
 
                citracover.UnlockBits(data);
 
                cbWarnaCoverHistogram.Text = "Luminosity";
                FormatHistogramCover(grafikCoverHistogram, "", "", LabelCover, LumCover, Color.FromArgb(0, 0, 0), Color.FromArgb(255, 255, 255), Color.Black, 0, 1);
                gbCoverHistogram.Enabled = true;
 
            }
            catch
            {
 
            }
            this.Cursor = Cursors.Default;
        }
    }
 
 
Private Sub btBrowseCoverHistogram_Click(sender As Object, e As EventArgs)
For i As Integer = 0 To 255
    LabelCover(i) = i
    LumCover(i) = 0
    RedCover(i) = 0
    GreenCover(i) = 0
 
    BlueCover(i) = 0
Next
Dim citracoverhistogram As [String] = GetCitraCover("JPEG (*.jpg)|*.jpg|Bitmaps (*.bmp)|*.bmp")
If citracoverhistogram IsNot Nothing Then
    txtCitraCoverHistogram.Text = citracoverhistogram
    AturCitraCover(citracoverhistogram)
    Me.Cursor = Cursors.WaitCursor
 
    Try
        Dim citracover As New Bitmap(citracoverhistogram)
        Dim data As BitmapData = citracover.LockBits(New System.Drawing.Rectangle(0, 0, citracover.Width, citracover.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb)
 
        Dim pointer As Pointer(Of Byte) = CType(data.Scan0, Pointer(Of Byte)) 'CODE ERROR START HERE

        Dim sisa As Integer = data.Stride - data.Width * 3
 

 
        For i As Integer = 0 To data.Height - 1
 
            For j As Integer = 0 To data.Width - 1
 
                Dim ratarata As Integer = CInt(Math.Truncate(0.114 * pointer(0) + 0.587 * pointer(1) + 0.299 * pointer(2)))
                Dim red As Integer = pointer(2)
                Dim green As Integer = pointer(1)
                Dim blue As Integer = pointer(0)
                '
                LumCover(ratarata) += 1
                RedCover(red) += 1
                GreenCover(green) += 1
                BlueCover(blue) += 1
                '
                pointer += 3
            Next
            pointer += sisa
        Next
 
        citracover.UnlockBits(data)
 
        cbWarnaCoverHistogram.Text = "Luminosity"
        FormatHistogramCover(grafikCoverHistogram, "", "", LabelCover, LumCover, Color.FromArgb(0, 0, 0), _
            Color.FromArgb(255, 255, 255), Color.Black, 0, 1)
 
        gbCoverHistogram.Enabled = True
 
    Catch
    End Try
    Me.Cursor = Cursors.[Default]
End If
End Sub
 
 
and I find the error message "Type Pointer is defined"
 
Would you help me please??
Posted 8-Jul-12 21:03pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Can you see the type 'Pointer' in the same line? Well, rename the variable 'pointer'. Remember that list language is not case-sensitive.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 470
1 mhegazy94 460
2 Ravi Bhavnani 190
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,135
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,619
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 9 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100