|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
adding images to a bitmapbut it does not the job what is wrong whit my code? 'add an image to the bitmap Private Function addImg(ByVal ibitmap As Image, ByVal imagename As String, ByVal ILeft As Integer, ByVal ITop As Integer) As Boolean Dim i As Image = Image.FromFile(imagename) Dim g As Graphics = Graphics.FromImage(ibitmap) g.DrawImage(i.Clone, ILeft, ITop, numwidth.Value, numheight.Value) g.Dispose() i.Dispose() End Function 'mosaic of images square Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If pb1.Image Is Nothing Then Exit Sub End If If pb1.Image.Width >= 250 Or pb1.Image.Height >= 250 Then ResizeToolStripMenuItem.PerformClick() End If Dim img As Image = pb1.Image Dim wi As Integer = img.Width Dim he As Integer = img.Height Dim bmp As New Bitmap((wi * 50), (he * 50)) 'make an array of structure pixel ( x ,y , color ) Dim pix() As pixel = img2pix(img) Dim pixe As Color Dim fil As String = String.Empty For z As Long = 0 To pix.GetUpperBound(0) pixe = ColorManagement.GetNearestColor(pix(z).col) addImg(bmp, retitem(pixe), pix(z).x, pix(z).y) Next Dim sdf As New SaveFileDialog sdf.AddExtension = True sdf.DefaultExt = ".png" If sdf.ShowDialog = Windows.Forms.DialogResult.OK Then bmp.Save(sdf.FileName, Imaging.ImageFormat.Png) Else bmp.Save(filePath & ".mosaic.png", Imaging.ImageFormat.Png) End If End Sub ' find the corresponding image this is working Function retitem(ByVal colo As Color) As String Return IO.Path.Combine(dirImg, colo.Name & ".jpg") End Function it's ok I have found the problem :)
"gillardg" <gillardg*remo***@live.be> a écrit dans le message de groupe de discussion : #ROaMq28JHA.5***@TK2MSFTNGP03.phx.gbl...Show quoteHide quote > hello i'm using this code to create big mosaic from image > but it does not the job what is wrong whit my code? > > 'add an image to the bitmap > Private Function addImg(ByVal ibitmap As Image, ByVal imagename As > String, ByVal ILeft As Integer, ByVal ITop As Integer) As Boolean > Dim i As Image = Image.FromFile(imagename) > Dim g As Graphics = Graphics.FromImage(ibitmap) > g.DrawImage(i.Clone, ILeft, ITop, numwidth.Value, numheight.Value) > g.Dispose() > i.Dispose() > End Function > > 'mosaic of images square > Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button4.Click > If pb1.Image Is Nothing Then > Exit Sub > End If > If pb1.Image.Width >= 250 Or pb1.Image.Height >= 250 Then > ResizeToolStripMenuItem.PerformClick() > End If > Dim img As Image = pb1.Image > Dim wi As Integer = img.Width > Dim he As Integer = img.Height > Dim bmp As New Bitmap((wi * 50), (he * 50)) > 'make an array of structure pixel ( x ,y , color ) > Dim pix() As pixel = img2pix(img) > Dim pixe As Color > Dim fil As String = String.Empty > For z As Long = 0 To pix.GetUpperBound(0) > pixe = ColorManagement.GetNearestColor(pix(z).col) > addImg(bmp, retitem(pixe), pix(z).x, pix(z).y) > Next > Dim sdf As New SaveFileDialog > sdf.AddExtension = True > sdf.DefaultExt = ".png" > If sdf.ShowDialog = Windows.Forms.DialogResult.OK Then > bmp.Save(sdf.FileName, Imaging.ImageFormat.Png) > Else > bmp.Save(filePath & ".mosaic.png", Imaging.ImageFormat.Png) > End If > End Sub > > ' find the corresponding image this is working > Function retitem(ByVal colo As Color) As String > Return IO.Path.Combine(dirImg, colo.Name & ".jpg") > End Function gillardg wrote:
> it's ok I have found the problem :) Then please post a short explanation, so that others with similar > problems might be able to benefit from this thread.
.net 3.5 with vs 2005
Need some help from VB Programmers... How to hide base class member variable in derived class (w/o shadows)? distributing software Alternative to strongly typed datasets Application Icon Uisng ADO.Net The Entity Framework "Random" numbers cause pattern? Need help in finding error in SOAP web service call create com object and register trouble |
|||||||||||||||||||||||