Private void pictureBox1_MouseClick(object sender, MouseEventArgs e) Save X1,Y1 mouse coordinate when user click on picture box 1 Private void Form1_Load(object sender, EventArgs e) Load and display statue bitmap on picture box 1 Create a 512x512 bitmap image using MS Paint Create second picture box 2 at least 32x32 pixel Create first picture box 1 at least 512x512 pixel Private const int pSize = 20 // pixel size Private bool mousePress = false // is left mouse pressed in picture box 2 Private int Y1 = 0 // picture box 1 mouse click y position Private int X1 = 0 // picture box 1 mouse click X position The code listed below contains a bare bone example on how to create a pixel image editor using the C# programming language on Microsoft Visual Studio 2022. I would suggest looking at that rather than what I have posted if performance is a concern. Marc's post notes LockBits and using that to modify the image directly in memory. The darker it is, the more the diff.): public static Bitmap Diff(Bitmap src1, Bitmap src2, int x1, int y1, int x2, int y2, int width, int height)īitmap diffBM = new Bitmap(width, height, PixelFormat.Format24bppRgb) Ĭolor col1 = src1.GetPixel(x1 + x, y1 + y) Ĭolor col2 = src2.GetPixel(x2 + x, y2 + y) Ĭolor newcol = Color.FromArgb(dif, dif, dif) It takes two images and produces a third greyscale image showing the differences between the two images as a greyscale tone level. A sample code routine (I use this for simple merge and compare functionality.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |