N
Nathan Sokalski
I have created declared a Bitmap using the following statement:
Dim bmp As New Bitmap(100, 100, PixelFormat.Format8bppIndexed)
Because the SetPixel() method is disabled and a Graphics object cannot be
created for indexed PixelFormats, I am not sure how to edit the Bitmap. I am
assuming that there is some class or technique other than the following:
Dim bmpdata As BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width,
bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed)
For y As Integer = 0 To bmp.Height - 1
For x As Integer = 0 To bmp.Width - 1
System.Diagnostics.Debug.WriteLine(System.Runtime.InteropServices.Marshal.ReadByte(bmpdata.Scan0,
y * bmpdata.Stride + x))
Next
Next
bmp.UnlockBits(bmpdata)
Which is basically just directly changing the data that will be saved when
the Bitmap is saved. However, using the technique shown above can make it
require multiple steps and calculations when drawing shapes such as
ellipses. Is there a more efficient way to edit an indexed Bitmap? Thanks.
Dim bmp As New Bitmap(100, 100, PixelFormat.Format8bppIndexed)
Because the SetPixel() method is disabled and a Graphics object cannot be
created for indexed PixelFormats, I am not sure how to edit the Bitmap. I am
assuming that there is some class or technique other than the following:
Dim bmpdata As BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width,
bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed)
For y As Integer = 0 To bmp.Height - 1
For x As Integer = 0 To bmp.Width - 1
System.Diagnostics.Debug.WriteLine(System.Runtime.InteropServices.Marshal.ReadByte(bmpdata.Scan0,
y * bmpdata.Stride + x))
Next
Next
bmp.UnlockBits(bmpdata)
Which is basically just directly changing the data that will be saved when
the Bitmap is saved. However, using the technique shown above can make it
require multiple steps and calculations when drawing shapes such as
ellipses. Is there a more efficient way to edit an indexed Bitmap? Thanks.