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
» android mobile app dev APK
Sun Jul 15, 2018 6:20 pm by Moti Barski

» android studio execises
Mon Jul 09, 2018 1:43 pm by Moti Barski

» problem with firebase authentication
Thu Jun 28, 2018 9:52 am by Moti Barski

» text art canvas
Wed Jun 20, 2018 8:55 pm by Moti Barski

» links/suggestions to become a programmer
Mon May 07, 2018 11:01 pm by Moti Barski

» java eclipse oxygen grimoire
Thu May 03, 2018 8:24 pm by Moti Barski

» forum logo by tf monkey
Wed May 02, 2018 10:17 pm by Moti Barski

» java and MySQL
Mon Apr 30, 2018 3:02 pm by Admin

» mini A.I puzzles
Mon Apr 23, 2018 11:38 am by Moti Barski

July 2018
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031    
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

Go down 
AuthorMessage
Admin
Admin
avatar

Posts : 108
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 : 108
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
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: