Re: SetPixel() / GetPixel() for Format32bppPArgb in VB using LockBits
- From: "Michael Phillips, Jr." <mphillips53@xxxxxxxxxxxxxxx>
- Date: Tue, 22 Aug 2006 11:49:51 -0400
Here is a suitable GetPixel
Private Function GetPixel32bppPArgb(ByRef bmp As Bitmap, ByVal x As Int32,
ByVal y As Int32) As Color
' 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,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
' Get the address of the first line.
Dim pBits As IntPtr = bmpData.Scan0
' Find the byte on which this scanline begins
Dim ByteIndex As Int32
ByteIndex = (bmpData.Height - y - 1) * bmpData.Stride
' Find the byte containing this pixel
ByteIndex += x * 4 ' advance 4 pixels
' get the color index
Dim A, R, G, B As Byte
B = System.Runtime.InteropServices.Marshal.ReadByte(pBits,
ByteIndex)
G = System.Runtime.InteropServices.Marshal.ReadByte(pBits, ByteIndex
+ 1)
R = System.Runtime.InteropServices.Marshal.ReadByte(pBits, ByteIndex
+ 2)
A = System.Runtime.InteropServices.Marshal.ReadByte(pBits, ByteIndex
+ 3)
' Unlock the bits.
bmp.UnlockBits(bmpData)
' construct the color
Dim color As Color
color = color.FromArgb(A, R, G, B)
GetPixel32bppPArgb = color
End Function
You should be able to create a SetPixel easily from the above
"pamela fluente" <pamelafluente@xxxxxxxxx> wrote in message
news:1156240236.437123.319730@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sorry! I made a mistake in my previous post.
The format I need is: ** Format32bppPArgb **
Thanks again for your help.
-P
pamela fluente ha scritto:
Hi dears,
I need an exact replacement of SetPixel() and GetPixel() functions
(VB.NET),
only for the specific format PixelFormat.Format64bppArgb, using
LockBits.
I have already browsed Bob's site, but I am too unfamiliar with this
stuff to attempt to produce myself these 2 functions.
I need those. Any help would be much appreciate. Thank you very much.
-Pam
.
- Follow-Ups:
- Re: SetPixel() / GetPixel() for Format32bppPArgb in VB using LockBits
- From: pamela fluente
- Re: SetPixel() / GetPixel() for Format32bppPArgb in VB using LockBits
- References:
- SetPixel() / GetPixel() for Format64bppArgb in VB using LockBits
- From: pamela fluente
- Re: SetPixel() / GetPixel() for Format32bppPArgb in VB using LockBits
- From: pamela fluente
- SetPixel() / GetPixel() for Format64bppArgb in VB using LockBits
- Prev by Date: Re: Creating a visual object
- Next by Date: Re: SetPixel() / GetPixel() for Format32bppPArgb in VB using LockBits
- Previous by thread: Re: SetPixel() / GetPixel() for Format32bppPArgb in VB using LockBits
- Next by thread: Re: SetPixel() / GetPixel() for Format32bppPArgb in VB using LockBits
- Index(es):
Relevant Pages
|