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
» vb.net convert array to xy coodinates
Fri Dec 08, 2017 2:18 pm by Admin

» JS javascript convert number to words
Wed Dec 06, 2017 1:23 pm by Moti Barski

» JS pascal triangle question
Mon Dec 04, 2017 9:54 am by Admin

» youtube emojis
Mon Dec 04, 2017 12:14 am by Admin

» vb.net pascal triangle
Sat Dec 02, 2017 10:10 am by Moti Barski

» puzzles at various levels
Sat Dec 02, 2017 8:06 am by Admin

» primitive tech
Fri Dec 01, 2017 8:02 pm by Admin

» course templets
Thu Nov 30, 2017 10:14 am by Moti Barski

» vb.net check if two rectangles overlap
Fri Nov 24, 2017 7:36 pm by Moti Barski

December 2017
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
31      
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 blogmarks  Social bookmarking live      

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 : 71
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 https://yotamarker.justforum.net
Admin
Admin
avatar

Posts : 71
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 https://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: