0

I'm using visual studios and programming in C#. Is it possible to move a PictureBox, using the picturebox.left function, and not have it always redraw my picture box but instead just change the position?

Thank you.

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
Desamos
  • 17
  • 6
  • 2
    I can't understand: if you move it then you must redraw it to see it in the new position. If Paint operation is onerous you may consider to a) post that code, maybe there is room for improvements or b) freeze it into a bitmap while dragging or c) use BitBlt to perform dragging before. In any way post MUCH more details and some code attempts, your question it's pretty vague now (see also [help]). – Adriano Repetti Jul 20 '15 at 22:52
  • I apologize. Maybe this will help: I have a png image in a picture box, and this image is considered my "player"/"character". He's moving left and right across my 2d map, but I am trying to fix some flickering issues. On top of that I will eventually want to move clouds and foreground left and right, but I am going to have the same flickering issues as I am having with my character. Does this help at all? @AdrianoRepetti – Desamos Jul 20 '15 at 22:59
  • OK, You may make it work but WinForms (and in general Windows UI controls) aren't made for this _almost real-time no-flickering_ jobs. You'd better to **paint** your image. You put a panel and in its Paint event you draw all your stuff then you activate double buffering for that panel (to stop flickering). Next step is to draw only what required (to increase performance). GDI+ isn't made for games and/or relatively _high_ speed graphics but you may find it satisfactory if you don't have a scene full of _stuff_ and you're not looking for high FPS. – Adriano Repetti Jul 20 '15 at 23:02
  • Alright thank you, I have just one more question. Is it possible to double buffer a png file rather than a bitmap? I want to have transparent images that is why I want to focus on using png. – Desamos Jul 20 '15 at 23:08
  • IMO not dupe but it contains link to nice example: https://channel9.msdn.com/coding4fun/articles/2D-Game-Primer-Visual-C – Adriano Repetti Jul 20 '15 at 23:08
  • when you _decode_ a .png you have a bitmap (a raster image) in memory. – Adriano Repetti Jul 20 '15 at 23:09
  • ah excellent, thank you for your help Adriano, looks like I need to do a lot of graphics studying to get the result I want. @AdrianoRepetti – Desamos Jul 20 '15 at 23:18
  • Not so much, examples are often bigger than required. To start you just need few lines of code... – Adriano Repetti Jul 21 '15 at 10:49

0 Answers0