lock and unlock image error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By daniel500013

Hi i have small question because i try get pixel color under my mouse and everything was good but when i open my game i got many errors with locking and unlocking image i trying fix it but i failed it. Someone could tell my how can i fix it ?

I using c# :slight_smile:

under i give image with my errors and code

:bust_in_silhouette: Reply From: wombatstampede

You don’t need to load an image. You get an image via GetViewport()…

var image = GetViewport().GetTexture().GetData();
image.Lock();
GD.Print(image.GetPixel(.....and so on.....));
image.UnLock();