Skip to content

ImageTexture

Eduard Gushchin edited this page Jul 1, 2026 · 2 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.ImageTexture
Namespace Electron2D
Kind class
Category Rendering

Overview

Provides an immutable image-backed 2D texture loaded from a PNG file.

Syntax

public sealed class Electron2D.ImageTexture : Electron2D.Texture2D

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Partial / Not verified
Out of profile: yes
Godot reference: ImageTexture

Image-backed texture resource loaded from PNG files or mounted res:// project resources.

Remarks

Electron2D.ImageTexture is a concrete Electron2D.Texture2D for project assets that need real pixel data during preview runtime rendering, screenshots, Electron2D.Sprite2D, Electron2D.TextureRect, Electron2D.TextureButton and Electron2D.CanvasItem.DrawTexture(Electron2D.Texture2D,Electron2D.Vector2,System.Nullable{Electron2D.Color}).

Electron2D 0.1.0 Preview supports non-interlaced PNG images with 8-bit RGB, RGBA, grayscale-alpha data and 1-bit, 2-bit, 4-bit or 8-bit indexed palette data. Unsupported or malformed files fail before a texture instance is returned.

Thread Safety

Instances are immutable after creation. Metadata and opacity queries are safe to call from any thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AtlasTexture
  • Electron2D.Texture2D

Members

Member Kind Summary
GetHeight() Method Gets the decoded image height in pixels.
GetWidth() Method Gets the decoded image width in pixels.
HasAlpha() Method Checks whether the decoded image contains transparent pixels or alpha metadata.
IsPixelOpaque(System.Int32, System.Int32) Method Checks whether a decoded image pixel is fully opaque.
LoadFromFile(System.String) Method Loads an Electron2D.ImageTexture from a PNG file or project resource path.

Member Details

GetHeight()

Kind: Method

public System.Int32 GetHeight()()

Summary

Gets the decoded image height in pixels.

Returns

The positive height of the decoded PNG image in pixels.

Thread Safety

This method is safe to call from any thread because Electron2D.ImageTexture instances are immutable after loading.

Since

This method is available since Electron2D 0.1.0 Preview.

GetWidth()

Kind: Method

public System.Int32 GetWidth()()

Summary

Gets the decoded image width in pixels.

Returns

The positive width of the decoded PNG image in pixels.

Thread Safety

This method is safe to call from any thread because Electron2D.ImageTexture instances are immutable after loading.

Since

This method is available since Electron2D 0.1.0 Preview.

HasAlpha()

Kind: Method

public System.Boolean HasAlpha()()

Summary

Checks whether the decoded image contains transparent pixels or alpha metadata.

Returns

true when the source PNG contained an alpha channel, transparency chunk or transparent palette entry; otherwise, false.

Thread Safety

This method is safe to call from any thread because Electron2D.ImageTexture instances are immutable after loading.

Since

This method is available since Electron2D 0.1.0 Preview.

IsPixelOpaque(System.Int32, System.Int32)

Kind: Method

public System.Boolean IsPixelOpaque(System.Int32, System.Int32)(System.Int32 x, System.Int32 y)

Summary

Checks whether a decoded image pixel is fully opaque.

Parameters

  • x: The pixel X coordinate in image space.
  • y: The pixel Y coordinate in image space.

Returns

true when the coordinate is inside the image and its alpha value is fully opaque; otherwise, false.

Thread Safety

This method is safe to call from any thread because Electron2D.ImageTexture instances are immutable after loading.

Since

This method is available since Electron2D 0.1.0 Preview.

LoadFromFile(System.String)

Kind: Method

public static Electron2D.ImageTexture LoadFromFile(System.String)(System.String path)

Summary

Loads an Electron2D.ImageTexture from a PNG file or project resource path.

Remarks

Relative paths are resolved by the current process in the normal .NET file-system manner. Paths beginning with res:// are resolved by the current Electron2D runtime resource source, which may be a project directory during development or exported resource packages in a player build. The returned texture is detached from the source file; later file changes do not mutate the instance.

The loader accepts non-interlaced PNG images with 8-bit RGB, RGBA and grayscale-alpha color data, plus indexed palette data with 1-bit, 2-bit, 4-bit or 8-bit palette indices. PNG transparency metadata is applied to Electron2D.ImageTexture.HasAlpha and Electron2D.ImageTexture.IsPixelOpaque(System.Int32,System.Int32).

Parameters

  • path: The absolute file path, relative file path, or res:// resource path to a PNG image.

Returns

A new immutable Electron2D.ImageTexture containing the decoded image pixels.

Exceptions

  • System.ArgumentException: Thrown when path is empty.
  • System.IO.FileNotFoundException: Thrown when path does not exist.
  • System.FormatException: Thrown when the PNG file is malformed or uses an unsupported PNG mode.

Thread Safety

This method performs file IO and should be called before sharing the texture across runtime systems.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Texture2D

Clone this wiki locally