pablogvivo
New member
- Joined
- Sep 2, 2010
- Messages
- 1
- Programming Experience
- Beginner
Hi, I´m trying convert an array to image. This picture is a dot to dot representation and as you can see have more noise but closer to reality
This one is the image create by vb and is more smooth but there is fake yellow line in the left box and the edge of the yellow box is noisy plus the hammer problem.
I stack the code at the end, valor array has a dimension of 500x375. I call first to dibujar subprocess and after that pass the rgb array to byte2image subprocess, hbmp array it´s the bmp header. So If you know what is the problem please help me .
Sorry for my english and thanks
This one is the image create by vb and is more smooth but there is fake yellow line in the left box and the edge of the yellow box is noisy plus the hammer problem.
I stack the code at the end, valor array has a dimension of 500x375. I call first to dibujar subprocess and after that pass the rgb array to byte2image subprocess, hbmp array it´s the bmp header. So If you know what is the problem please help me .
Sorry for my english and thanks
VB.NET:
Public Sub Byte2Image(ByRef NewImage As Image)
Dim ImageStream As MemoryStream
ReDim total(rgb.Length + hbmp.Length)
hbmp.CopyTo(total, 0)
rgb.CopyTo(total, hbmp.Length - 1)
Try
If total.GetUpperBound(0) > 0 Then
ImageStream = New MemoryStream(total)
NewImage = Image.FromStream(ImageStream)
Else
NewImage = Nothing
End If
Catch ex As Exception
NewImage = Nothing
End Try
End Sub
Public Sub dibujar()
Dim g As Byte = 0
Dim b As Byte = 0
Dim r As Byte = 0
Dim oPen As Pen
Dim open2 As Pen
Dim i As Integer
Dim j As Integer
Dim valoract As UShort
Dim valorpos As UShort
'Escalado para que el valor quede entre 0 y 255
Const escala = 0.767
oPen = New Pen(Color.YellowGreen, 1)
oGrafico.Clear(Color.Black)
'Como hay 376 valores le dejamos un margen de 30 a cada lado
j = 0
For i = 1 To 375
If valor(veces, i) > Val(txtlimite.Text) Then
If valor(veces, i) > 2333 And valor(veces, i) < 2666 Then
r = 255
g = 255 - ((valor(veces, i) - 2333) * escala)
b = 0
ElseIf valor(veces, i) >= 2666 And valor(veces, i) < 3000 Then
r = 255 - ((valor(veces, i) - 2666) * escala)
g = 0
b = 0
ElseIf valor(veces, i) > 2000 And valor(veces, i) < 2333 Then
r = 255
b = 255 - ((valor(veces, i) - 2000) * escala)
g = 255
Else
r = 0
g = 0
b = 0
End If
open2 = New Pen(Color.FromArgb(255, r, g, b), 1)
valoract = valor(vglobal.veces, i) / 20
valorpos = valor(vglobal.veces, i + 1) / 20
oGrafico.DrawLine(oPen, i + 10, 260 - valoract, i + 11, 260 - valorpos)
oGrafico2.DrawLine(open2, 50 + vglobal.veces, i + 10, 50 + vglobal.veces, i + 11)
End If
rgb(((veces) * 1128) + j) = r 'Guarda la componente red
rgb(((veces) * 1128) + j + 1) = b 'Guarda la componente blue
rgb(((veces) * 1128) + j + 2) = g 'Guarda la componente green
j = j + 3
Next
End Sub