Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

[vb.net 2003] Unir imagenes

Estas en el tema de [vb.net 2003] Unir imagenes en el foro de Visual Basic clásico en Foros del Web. Buenas, estoy intentando unir verticalmente una serie de imagenes que etngo en una carpeta, para despues guardarlo como un bmp o jpg (me es indiferente). ...
  #1 (permalink)  
Antiguo 12/11/2008, 05:44
 
Fecha de Ingreso: abril-2007
Mensajes: 82
Antigüedad: 17 años
Puntos: 0
[vb.net 2003] Unir imagenes

Buenas, estoy intentando unir verticalmente una serie de imagenes que etngo en una carpeta, para despues guardarlo como un bmp o jpg (me es indiferente).

Para ello cojo una imagen de 1x1px para tener una referencia de donde dibujarlo.

El problema es que a la hora de guardar la imagen, no me realiza los cambios (no aparecen las imagenes unidas) sino que sigue el archivo de 1x1px (pero la fecha de edicion del archivo si que cambia, asi que guardar guarda algo).

Dejo el codigo:

Código:
Dim i As Integer
        Dim axLayer As ESRI.MapObjects2.Core.MapLayer
        Dim img() As Bitmap
        Dim z As Integer = 0
        Dim imgFinal As Bitmap = Bitmap.FromFile("C:\aaa.bmp")
        Dim g As Graphics = Graphics.FromImage(imgFinal)
        Dim intHeigh As Integer = 0
        Try
            'Esto no tiene nada que ver con lo dicho, solo pongo visible un componente
            'del que voi a exportar las imagenes bmp a unir
            If Not Me.axLeyenda.Visible Then
                axLeyenda.setMapSource(AxMapa)
                axLeyenda.LoadLegend(True)
                axLeyenda.ShowAllLegend()
                axLeyenda.set_Active(0, True)
                sRedimensionarControles_VisualizarLeyenda()
            End If
            For i = 0 To Me.AxMapa.Layers.Count - 1
                axLayer = Me.AxMapa.Layers.Item(i)
                If axLayer.Visible Then                    
                    If fCheckLayerInMap(axLayer) Then
                        'Exporto la imagen del componente (solo si se cumplen unas condiciones
                        '(comprobado que se exportan correctamente)
                        Me.axLeyenda.ExportToBmp("C:\Borrame\" & i & ".bmp", i)
                        ReDim Preserve img(z)
                        img(z) = New Bitmap("C:\Borrame\" & i & ".bmp")
                        'Aqui lo dibujo
                        g.DrawImage(img(z), 0, intHeigh)
                        intHeigh = intHeigh + img(z).Height
                        z += 1
                    End If
                End If
            Next
           imgFinal.Save("C:\leyenda.bmp", Imaging.ImageFormat.Bmp)
        Catch ex As Exception
            MsgBox("Error: " & ex.Message & vbNewLine & "Traza: " & ex.StackTrace)
        Finally
            sRedimensionarControles_OcultarLeyenda()
            i = Nothing
            axLayer = Nothing
            img = Nothing
            z = Nothing
            g.Dispose()
            g = Nothing
            imgFinal = Nothing
            intHeigh = Nothing
        End Try
  #2 (permalink)  
Antiguo 12/11/2008, 06:25
 
Fecha de Ingreso: abril-2007
Mensajes: 82
Antigüedad: 17 años
Puntos: 0
Respuesta: [vb.net 2003] Unir imagenes

Solucionado, gracias igualmente.

Pongo el codigo por si a alguien le sirve:

Código:
Private Sub sImprimirLeyenda()
        Dim i As Integer
        Dim axLayer As ESRI.MapObjects2.Core.MapLayer
        Dim img() As Bitmap
        Dim z As Integer = 0
        Dim imgFinal As Bitmap
        Dim g As Graphics
        Dim intHeigh As Integer = 0
        Try
            If Not Me.axLeyenda.Visible Then
                axLeyenda.setMapSource(AxMapa)
                axLeyenda.LoadLegend(True)
                axLeyenda.ShowAllLegend()
                axLeyenda.set_Active(0, True)
                sRedimensionarControles_VisualizarLeyenda()
            End If
            For i = 0 To Me.AxMapa.Layers.Count - 1
                axLayer = Me.AxMapa.Layers.Item(i)
                If axLayer.Visible Then
                    If fCheckLayerInMap(axLayer) Then
                        Me.axLeyenda.ExportToBmp("C:\Borrame\" & i & ".bmp", i)
                        ReDim Preserve img(z)
                        img(z) = New Bitmap("C:\Borrame\" & i & ".bmp")
                        'g.DrawImage(img(z), 0, intHeigh)
                        intHeigh = intHeigh + img(z).Height
                        'imgFinal.Height = intHeigh
                        z += 1
                    End If
                End If
            Next
            imgFinal = New Bitmap(Me.axLeyenda.Width, intHeigh, Imaging.PixelFormat.Format32bppArgb)
            g = Graphics.FromImage(imgFinal)
            intHeigh = 0
            For i = 0 To img.Length - 1
                g.DrawImage(img(i), 0, intHeigh)
                intHeigh = intHeigh + img(i).Height
            Next
           imgFinal.Save("C:\leyenda.bmp", Imaging.ImageFormat.Bmp)
        Catch ex As Exception
            MsgBox("Error: " & ex.Message & vbNewLine & "Traza: " & ex.StackTrace)
        Finally
            sRedimensionarControles_OcultarLeyenda()
            i = Nothing
            axLayer = Nothing
            img = Nothing
            z = Nothing
            g.Dispose()
            g = Nothing
            imgFinal = Nothing
            intHeigh = Nothing
        End Try
    End Sub
Saludos!
  #3 (permalink)  
Antiguo 06/11/2010, 11:53
Avatar de jhavierc  
Fecha de Ingreso: noviembre-2010
Ubicación: Bogotá/Colombia
Mensajes: 1
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: [vb.net 2003] Unir imagenes

Hola como estas, lo que pasa es que tambien estoy trabajando en un proyecto de clases para unir imagenes y pues veo que tu tienes la solucion, me gustaria que me hucieras el favor de mandarme una ejemplo donde aplicas tu funcion, un ejemplo de codigo fuente

graciasss

escribeme lo mas antes posible por favor
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:25.