I was hoping to use the get_pixel method to get the color of the pixel points of a TextureRect's texture image, but it seems to be going wrong. The texture is displayed correctly centered on the screen (windowed window), but the color that get_pixel gets doesn't match what's on the screen, and it seems that the image that the get_image method gets doesn't exactly overlap with the texture image that's displayed on the screen.

Can anyone give me an idea? Thank you.

  • xyz replied to this.

    xyz
    I get the coordinate of pixel using function "get_global_mouse_position"

    • xyz replied to this.

      Capixo That'll work only if your window resolution and proportion exactly matches image's pixel size and image is scaled/positioned to exactly fill the entire window from border to border. Otherwise there will be a mismatch because pixels drawn on screen wouldn't correspond to the original pixel data of the image.

        xyz Hello. Thank you for notification. In the case window resolution and proportion doesn't match image's pixel size but image is scaled/positioned to exactly fill the entire window by anchors preset in full-rect mode, how can I make it right?

        I had made the TextureRect which has image at position(0,0), set the image as "ignore size" stretch mode, and put its anchor in Full-Rect preset mode. I wish I know what settings I need to change more. Thank you.

        • xyz replied to this.

          Capixo You need to remap the coordinates from screen space to bitmap's pixel space.

            xyz Really appreciate your suggestion. Thank you.

            Can anyone tell me how to remap the screen pixel space to texture image pixel space? Otherwise I need prepare different sizes and resolutions images for one texture.

            • xyz replied to this.