Необходимо прочитать png-рисунок 256x256 и занести цвет каждаго пиксела в матрицу 256x256, те пиксел 0,0 в эл матрицы (0,0).
P.S. - такой темы не нашел...
Dim b As New System.Drawing.Bitmap("C:\1.png")
MessageBox.Show(b.GetPixel(0, 0).ToString)
MessageBox.Show(Convert.ToString(b.Height))
MessageBox.Show(Convert.ToString(b.Width))
b.SetPixel(0, 0, Color.Black)
Private Sub LockUnlockBitsExample()
' Create a new bitmap.
Dim bmp As New Bitmap("c:\picture.png")
' Lock the bitmap's bits.
Dim rect As New Rectangle(0, 0, bmp.Width, bmp.Height)
Dim bmpData As System.Drawing.Imaging.BitmapData = bmp.LockBits(rect, _
Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat)
' Get the address of the first line.
Dim ptr As IntPtr = bmpData.Scan0
' Declare an array to hold the bytes of the bitmap.
' This code is specific to a bitmap with 24 bits per pixels.
Dim bytes As Integer = bmp.Width * bmp.Height * 3
Dim rgbValues(bytes - 1) As Byte
' Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes)
' Set every red value to 255.
For counter As Integer = 0 To rgbValues.Length - 1 Step 3
rgbValues(counter) = 255
Next
' Copy the RGB values back to the bitmap
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes)
' Unlock the bits.
bmp.UnlockBits(bmpData)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim b As Image = Image.FromFile("C:\1.png")
Me.CreateGraphics.DrawImage(b, 0, 0, 256, 256)
End Sub
Me.CreateGraphics.DrawImage(bit_read.My.Resources._1, 0, 0, 256, 256)
Public Class Form1
Dim b As Image = Image.FromFile("C:\1.png")
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawImage(b, 0, 0, 256, 256)
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.BackgroundImage = Image.FromFile("C:\1.png")
End Sub
End Class
Dim b As Image = Image.FromFile("C:\1.png")
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawImage(b, 0, 0, 256, 256)
End Sub
Public Class Form1
Dim b As Image = Image.FromFile("C:\1.png")
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawImage(b, 0, 0, 256, 256)
End Sub
End Class
Сейчас этот форум просматривают: AhrefsBot и гости: 65