hi to all....

actually i m facing a problem..i had convert the vb to c# code using http://www.carlosag.net/Tools/CodeTranslator/

wen i try run it ..i get the error...


here i copied the small part of VB code...that i face the error

Private Sub GenerateImage()

        ' Create a Bitmap Object
        Dim xBmp As Bitmap = New Bitmap(m_Width, m_Height, PixelFormat.Format32bppArgb)

        ' Create a Graphics Object from the Bitmap Object
        Dim xGraf As Graphics = Graphics.FromImage(xBmp)

        ' Set the Graphics Object Smoothing Mode
        xGraf.SmoothingMode = SmoothingMode.HighQuality

        ' Create the Rectangle Object
        Dim xRect As Rectangle = New Rectangle(0, 0, m_Width, m_Height)

        ' Create  the Hatch Brush used for the Background 
        ' and Fill it in the Graphics Object
        Dim hatchBrush As HatchBrush = New HatchBrush(m_BackGroundType, m_BackGroundSubColor, m_BackGroundColor)
        xGraf.FillRectangle(hatchBrush, xRect)

        ' Set up the Captcha Text Font.
        Dim size As SizeF
        Dim fontSize As Single = xRect.Height + 1
        Dim font As Font

        ' Adjust the font size until the text fits within the image.
        Do
            fontSize = fontSize - 1
            font = New Font(m_FontFace, fontSize, FontStyle.Bold)
            size = xGraf.MeasureString(m_Text, font)
        Loop While size.Width > xRect.Width

        ' Set up the text format.
        Dim format As StringFormat = New StringFormat()
        format.Alignment = StringAlignment.Center
        format.LineAlignment = StringAlignment.Center

        ' Create a path using the text and warp it randomly.
        Dim path As GraphicsPath = New GraphicsPath()
        path.AddString(m_Text, font.FontFamily, CType(font.Style, Integer), font.Size, xRect, format)

        Dim Points() As PointF = { _
            New PointF(m_Random.Next(xRect.Width) / 4.0F, m_Random.Next(xRect.Height) / 4.0F), _
            New PointF(xRect.Width - m_Random.Next(xRect.Width) / 4.0F, m_Random.Next(xRect.Height) / 4.0F), _
            New PointF(m_Random.Next(xRect.Width) / 4.0F, xRect.Height - m_Random.Next(xRect.Height) / 4.0F), _
            New PointF(xRect.Width - m_Random.Next(xRect.Width) / 4.0F, xRect.Height - m_Random.Next(xRect.Height) / 4.0F) _
                        }

        Dim matrix As Matrix = New Matrix()
        matrix.Translate(0.0F, 0.0F)

        path.Warp(Points, xRect, matrix, WarpMode.Perspective, 0.0F)

        xGraf.DrawPath(New Pen(m_ForeColor), path)

        ' Clean up.
        font.Dispose()
        hatchBrush.Dispose()
        xGraf.Dispose()

        ' Set the image.
        m_Image = xBmp

    End Sub

#End Region ' End Public Methods

here C# code based on above code

private void GenerateImage() {
        //  Create a Bitmap Object
        //Bitmap xBmp = new Bitmap(m_Width, m_Height, PixelFormat.Format32bppArgb);
        Bitmap xBmp = new Bitmap(PixelFormat.Format32bppArgb,n_Width, m_Height);        //  Create a Graphics Object from the Bitmap Object
        Graphics xGraf = Graphics.FromImage(xBmp);
        //  Set the Graphics Object Smoothing Mode
        xGraf.SmoothingMode = SmoothingMode.HighQuality;
        //  Create the Rectangle Object
        Rectangle xRect = new Rectangle(0, 0, n_Width, m_Height);
        //  Create  the Hatch Brush used for the Background 
        //  and Fill it in the Graphics Object
        HatchBrush hatchBrush = new HatchBrush(m_BackGroundType, m_BackGroundSubColor, m_BackGroundColor);
        xGraf.FillRectangle(hatchBrush, xRect);
        //  Set up the Captcha Text Font.
        SizeF size;
        float fontSize = (xRect.Height + 1);
        Font font;
        //  Adjust the font size until the text fits within the image.
        for (
        ; (size.Width > xRect.Width); 
        ) {
            fontSize = (fontSize - 1);
            font = new Font(m_FontFace, fontSize, FontStyle.Bold);
            size = xGraf.MeasureString(m_Text, font);
        }
        //  Set up the text format.
        StringFormat format = new StringFormat();
        format.Alignment = StringAlignment.Center;
        format.LineAlignment = StringAlignment.Center;
        //  Create a path using the text and warp it randomly.
        GraphicsPath path = new GraphicsPath();
        path.AddString(m_Text, font.FontFamily, ((int)(font.Style)), font.Size, xRect, format);
        PointF[] Points;
        new PointF(m_Random.Next(xRect.Width) / 4.0F, m_Random.Next(xRect.Height) / 4.0F);
        new PointF(xRect.Width - m_Random.Next(xRect.Width) / 4.0F, m_Random.Next(xRect.Height) / 4.0F);
        new PointF(m_Random.Next(xRect.Width) / 4.0F, xRect.Height - m_Random.Next(xRect.Height) / 4.0F);
        new PointF(xRect.Width - m_Random.Next(xRect.Width) / 4.0F, xRect.Height - m_Random.Next(xRect.Height) / 4.0F);
        Matrix matrix = new Matrix();
        matrix.Translate(0.0F, 0.0F);
        path.Warp(Points, xRect, matrix, WarpMode.Perspective, 0.0F);
        xGraf.DrawPath(new Pen(m_ForeColor), path);
        //  Clean up.
        font.Dispose();
        hatchBrush.Dispose();
        xGraf.Dispose();
        //  Set the image.
        m_Image = xBmp;
    }

the red highlight is error...
plz help meeeeeee

Try modified statement what you mentioned in red font

Bitmap bm = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Rectangle rect = new Rectangle(0, 0, Width, Height);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.