I am trying to edit 8bpp pixels. Since this PixelFormat is indexed, I know that it uses a color table to map pixel values. Despite the fact that I can edit the bitmap by converting it to 24bpp, editing 8bpp is much faster (13ms versus 3ms). But changing each value when accessing an 8bpp bitmap results in some random rgb colors, although the PixelFormat remains 8bpp.
I am currently developing in C #, and the algorithm is as follows:
(WITH#)
1- Download the original 8bpp bitmap
2- Create an empty temporary raster map with 8bpp with the same size as the original
3-LockBits both bitmaps and, using P / Invoke, calling the C ++ method, where I pass Scan0 to each BitmapData object. (I used the C ++ method as it provides better performance when iterating through Bitmap pixels)
(C ++)
4 Create the int [256] palette according to some parameters and edit the temp bytes by passing the original pixel values through the palette.
(WITH#)
5 UnlockBits.
My question is: how to edit pixel values without any weird rgb colors or is it even better to edit the 8bpp bitmap color table?
source
share