battle programmers alliance

battle programminga forum for elite programmerswith extreme will powerto sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Search
 
 

Display results as :
 
Rechercher Advanced Search
Latest topics
» xamarin c# manual image app walkthrough
Sat Aug 12, 2017 2:08 pm by Moti Barski

» win10 shortcut keys
Wed Aug 09, 2017 2:40 am by Moti Barski

» vb.net region
Sat Aug 05, 2017 12:25 am by Moti Barski

» visual studio 2017 xamarin c# hello world walkthrough
Sat Jul 29, 2017 11:34 am by Admin

» gear s3 frontier s voice command list
Sat Jul 22, 2017 7:07 pm by Moti Barski

» how to use magnet links
Wed Jun 28, 2017 3:41 am by kurosen

» evolution of code
Mon Jun 12, 2017 12:08 am by kurosen

» chicken bot
Sat Apr 29, 2017 11:09 am by Moti Barski

» vb.net convert to binary
Thu Apr 27, 2017 7:48 am by Moti Barski

August 2017
SunMonTueWedThuFriSat
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendarCalendar
Social bookmarking
Social bookmarking Digg  Social bookmarking Delicious  Social bookmarking Reddit  Social bookmarking Stumbleupon  Social bookmarking Slashdot  Social bookmarking Yahoo  Social bookmarking Google  Social bookmarking Blinklist  Social bookmarking Blogmarks  Social bookmarking Technorati  

Bookmark and share the address of battle programmers alliance on your social bookmarking website
Share | 
 

 vb.net image slicer

View previous topic View next topic Go down 
AuthorMessage
Admin
Admin
avatar

Posts : 53
Join date : 2011-08-01

PostSubject: vb.net image slicer   Wed Oct 26, 2011 12:01 pm

the image is sliced to 121 even pieces as .bmp files
in the code the bitmap.save gdi error is fixed, no problemo .
you can hard code to get another number of slices in your needed size ( height & width wize ).

Code:
Public Class Form1
    Dim bitmap1 As Bitmap
    Dim outputPath As String = Nothing
    Private Sub btnInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInput.Click
        Try
            OpenFileDialog1.ShowDialog()
            Label2.Visible = False
            Label2.Text = Nothing
            Dim fs As IO.FileStream = New IO.FileStream(OpenFileDialog1.FileName, IO.FileMode.Open)
            bitmap1 = Image.FromStream(fs)
            fs.Close()
            PictureBox1.Image = bitmap1
        Catch ex As Exception
            MsgBox("select an input path picture file")
        End Try
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog2.FileName = Nothing
    End Sub

    Private Sub btnOutput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOutput.Click
        Try
            OpenFileDialog2.ShowDialog()
            outputPath = OpenFileDialog2.FileName
            outputPath = outputPath.Substring(0, outputPath.LastIndexOf("\") + 1)
            Label1.Text = outputPath
            Dim bmts As New Bitmap(bitmap1.Width \ 11, bitmap1.Height \ 11)
            For i = 1 To 11
                For j = 1 To 11
                    For hj = 1 To bitmap1.Height \ 11 - 1 ' y of now picture
                        For wi = 1 To bitmap1.Width \ 11 - 1 ' x of now picture
                            bmts.SetPixel(wi, hj, bitmap1.GetPixel(wi + (j - 1) * (bitmap1.Width \ 11), hj + (i - 1) * (bitmap1.Height \ 11))) 'fix
                        Next
                    Next
                    Dim bitmapToSave As New Bitmap(bmts)
                    bitmapToSave.Save(outputPath & (11 * (j - 1) + i) & ".bmp", Imaging.ImageFormat.Bmp)
                Next
            Next
            Label2.Text = "image slicing completed"
            Label2.Visible = True
        Catch ex As Exception
            MsgBox("have you selected an input picture ? is it standard size ?, have you selected a file in a output directory with no files named 1 - 121.bmp")
        End Try
    End Sub
End Class


_________________
kurayami no kagi
Back to top Go down
View user profile http://yotamarker.justforum.net
Admin
Admin
avatar

Posts : 53
Join date : 2011-08-01

PostSubject: form controls   Wed Oct 26, 2011 12:30 pm

after :
opening vb.net 2010, project, new
toolbox :
drag to the form the controls :
2 buttons, picturebox, 2 openfiledialog, 2 lables.
set theire properties (by right clicking them) :
name : btninput, text : input
name : btnoutput, text : output
label2 : set visible property to false
picturebox1 : dock it from its dock property.

_________________
kurayami no kagi
Back to top Go down
View user profile http://yotamarker.justforum.net
 
vb.net image slicer
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» How do I make the login popup show an Image, instead of it's bland colors
» Roster image
» The header image keeps going invisible.
» Tiling image behind banner on PhpBB?
» How do you copy image URLs?

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: