What method can be used to access an already existing image, for subsequent changes (specifically, you need to open the image, draw something by the pixels using the SetPixel (); method, save)

  • one
    Could you add your question? (Because now it is not clear what you want to do). - user227049
  • What are you using: WinForms or WPF? - Alexander Petrov
  • @AlexanderPetrov WF - ZOOM SMASH

2 answers 2

You need a class Bitmap . It has methods GetPixel and SetPixel .

For example:

 var bmp = new Bitmap(path); bmp.SetPixel(0, 0, Color.Black); bmp.Save(newpath); 

For fast processing of many pixels, you will need LockBits .

  • And he himself did not guess before? I think we need something else. - Qwertiy
  • one
    @Qwertiy: Well, let him ask clarifying questions. I'm a bad telepath today. Well, let the search brings better here :) - VladD
  • It would have been better if he answered stackoverflow.com/q/594977/178988 - it’s more interesting there. - Qwertiy
  • @Qwertiy: java? o_O - VladD
  • Rather, winapi on Java))) But the question is interesting. But it is almost closed. And in general, why are you not appearing in the re-opening chat? - Qwertiy

Image loading like so:

 Bitmap image = Bitmap(/*fileName*/); 

Option without file blocking:

 public static Bitmap LoadBitmap(string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) return new Bitmap(fs); } 

Source - here by the way a lot of interesting information.