❔ Problem with Dictionary<ulong, Image> (Strange work of memory access)
Concept of my system: A system that draws a picture with stickers, each of the stickers can be moved, there can be an unlimited number of stickers.
Code with explanations in comments:
Problem:
Each time you use this function, a new picture should appear with ALL stickers and the sticker that we moved to a new location. However, it happens that the sticker is duplicated and there are several of them.
The suggestion line
I am using .NET 7.0
Code with explanations in comments:
Problem:
Each time you use this function, a new picture should appear with ALL stickers and the sticker that we moved to a new location. However, it happens that the sticker is duplicated and there are several of them.
The suggestion line
image.Mutate(x => x.DrawImage(stickerImage, new Point(sticker.PositionX, sticker.PositionY), 1f)); updates the Dictionary directly, though it shouldn't be, presumably because C# has a memory bug here.I am using .NET 7.0