Need to clip pictures in VB.NET

I am trying to make a program that can spilt characters from a antibot image into their own files. The antibot images is made like this: [6px nothing, 6px character, 1px nothing, 6px sharacter, 1px nothing, 6px charater], i thing you got the idea.

Example picture:

I tried to modify the code found here: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=373322&SiteID=1

but i didnt manage to make it work.

Ill be very grateful for a sulotion.

 

PS: I'm sorry about my bad English, it is not my primary lanuage.

 

EDIT: Opps, i first now se that i postet in wrong category. I'm using VB.NET 2005



Answer this question

Need to clip pictures in VB.NET

  • Minakovic

    Thank you very mutch! This is exactly what i need!

    Thanks for a fast and good answer!


  • Jorg Plumacher

    Hi,

    If your image is always the same format as the one in your sample, then you can use this function I wrote:



    Public Function GetDigitImage(ByVal source As Image, ByVal placement As Integer) As Image
    Dim bmp As Bitmap = CType(source, Bitmap)
    Return bmp.Clone(New Rectangle((placement*7) + 6, 0, 6, bmp.Height), bmp.PixelFormat)
    End Function



    The function above expect the source of the image (which is the loaded image, like your sample), and the placement is the digit you want to extract, possible values is 0 to get the first digit, upto 6 to get the last digit.

    Example of use:



    Dim source As Image = Image.FromFile("012fa1b.png");

    ' Here's the digits images:
    Dim digit1 As Image = GetDigitImage(source, 0);
    Dim digit2 As Image = GetDigitImage(source, 1);
    Dim digit3 As Image = GetDigitImage(source, 2);
    Dim digit4 As Image = GetDigitImage(source, 3);
    Dim digit5 As Image = GetDigitImage(source, 4);
    Dim digit6 As Image = GetDigitImage(source, 5);
    Dim digit7 As Image = GetDigitImage(source, 6);



    Hope this helps,

    -chris


  • Need to clip pictures in VB.NET