문제

I have read through several articles which are alternatives to using setpixel/getpixel but I am not seeing how they relate to my issue.

I have a multicoloured image which (depending on dynamic values taken from DB) changes the color of each pixel color group to a new color.

Lets say I want all pixels with Argb value of -989556 changed to -16 & all pixels with Argb value of -1331 changed to -5383962. I am currently looking at every pixel in the Bitmap and checking their value, if they match then they are changed using setpixel.

I am sure there must be a better way but I am being too dim to see it!

도움이 되었습니까?

해결책

Take a look at ImageAttributes.SetRemapTable

Another example.

다른 팁

If you are changing entire colors then you probably do not want to change them on a per pixel basis. There is a color transformation matrix that should allow you to change all pixles of a color in an image in a few lines of code, without having to loop through and manipulate each pixel of an image, which is horrendously slow.

See these links:

http://msdn.microsoft.com/en-us/library/6tf7sa87(v=vs.71).aspx

http://msdn.microsoft.com/en-us/library/system.drawing.imaging.colormatrix.aspx

Use bitmap, BitBlt functionality. I show an example in here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top