cPy.cImage module#

class cImage[source]#

Bases: object

Main class for handling raster images.
  • Provides functionality for creating, loading, manipulating, and querying

image data. Supports various pixel formats, mipmapping, and compression operations.
Designed to be compatible with OpenGL texture uploads.
static CalcImageSize(Format: any, Width: int, Height: int, Depth: int, MipMapCount: int) int[source]#
Calculates total size in bytes for an image with given parameters.
MipMapsAll: int = 127#
Default max count of mipmaps
Copy(Pixels: any, Format: any, Width: int, Height: int, Depth: int, MipMapCount: int)[source]#
Copies data from a raw buffer.
Set(Pixels: any, Format: any, Width: int, Height: int, Depth: int, MipMapCount: int)[source]#
Sets the image to point to existing memory (or adopts it).
SetHeight(Height: int)[source]#
Create(Format: any, Width: int, Height: int, Depth: int, MipMapCount: int)[source]#
Allocates memory for a new image.
Free()[source]#
Releases the pixel memory.
GetWidth(MipMapLevel: int) int[source]#
GetHeight(MipMapLevel: int) int[source]#
GetDepth(MipMapLevel: int) int[source]#
GetFormat() any[source]#
GetSize() int[source]#
GetPixels(MipMapLevel: int) any[source]#
GetMipMapCount() int[source]#
GetMipMapCountFromDimensions() int[source]#
GetDimension() any[source]#
SwapChannels(Ch0: int, Ch1: int) bool[source]#
RemoveChannels(KeepCh0: bool, KeepCh1: bool = True, KeepCh2: bool = True, KeepCh3: bool = True) bool[source]#
InvertChannel(Ch: int) bool[source]#
CopyChannel(From: int, To: int) bool[source]#
ToFormat(Format: any) bool[source]#
Uncompress()[source]#
Dxt3, Dxt5 -> Rgba8
Compress()[source]#
Rgba8 -> Dxt5
ToGrayScale() bool[source]#
Rgb16, Rgba16 -> R16
ToNormalMap(Format: any, Z: float = 1.0, OldAlpha: bool = False) bool[source]#
“OldAlpha” works only if(Rgba8 == m_Format && Rgba8 == Format)
CreateMipMaps(MipMapCount: int) bool[source]#
Generates mipmaps for the image. Not supported for compressed formats.
RemoveMipMaps()[source]#
!Compressed
GetPixelR8(X: int, Y: int) any[source]#
Returns pixel intensity. Assumes R8 format.
SetPixelR8(X: int, Y: int, p: any)[source]#
MergeRgb8(From: cImage, X: int, Y: int)[source]#
MergeRgba8(From: cImage, X: int, Y: int, ColorAsAlpha: bool)[source]#
Flip() bool[source]#
Flips the image vertically. Supports Plain, Packed, and Compressed formats.
Resize(Width: int, Height: int) bool[source]#
Resizes the image using resampling. Plain formats only.
Decrease2X() bool[source]#
Plain formats && !Cube
MakePowerOfTwo() bool[source]#
Resizes the image to the nearest power of two dimensions.
Make2D(Square: bool = True, DepthStep: int = 1) bool[source]#
Converts a 3D volume texture into a 2D strip of slices.
CreateSevenLods(SaveAs: str = 'data/textures/SevenLods.dds')[source]#
Converts 3D texture to 2D set of depth slices