BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›Pixmap

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TIllegalArgumentException
    • TInvalidEnumException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
    • IIterable
    • IIterator
    • ICloseable

    Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts

    Color

    • Introduction
    • SColor8
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • FileSystem

    • Introduction
    • IFileWalker
    • SFileAttributes
    • EFileWalkOption
    • EFileWalkResult
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • Glob

    • Introduction
    • EGlobOptions
    • TGlobIter
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • IO

    • Introduction
    • MaxIO
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
  • BRL.Math
  • Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject

    MaxUnit

    • Introduction
    • TTest
    • TAssert
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • Path

    • Introduction
    • TPath
    • IPathWalker
    • SPathAttributes
    • TPathDirIterator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PolledInput
  • BRL.RamStream
  • Random

    • Introduction
    • TRandomDefault

    RectPacker

    • Introduction
    • EPackingMethod
    • SPackedRect
    • TPackedSheet
    • TRectPacker

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Time

    • Introduction
    • ETimeUnit
    • TTimeoutException

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Pub

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • StdC

    • Introduction
    • SDateTime
  • Pub.xmmintrin

Collections

    IntMap

    • Introduction
    • TIntMap

    ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    ObjectMap

    • Introduction
    • TObjectMap

    PtrMap

    • Introduction
    • TPtrMap

    StringMap

    • Introduction
    • TStringMap

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

Math

    Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI

    Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I
    • SVec4D
    • SVec4F
    • SVec4I

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

Net

    Http

    • Introduction
    • THttpClient
    • THttpRequest
    • THttpResponse
    • THttpResult
    • TUrl
    • ICompleteListener
    • ICookie
    • THttpClientException
    • THttpCookie
    • THttpCookieBuilder
    • THttpField
    • THttpFields
    • TRetryPolicy
    • TUrlBuilder
    • TContent
    • TStringContent
    • TStreamContent
    • TBytePtrContent
    • TByteArrayContent
    • TBankContent
    • TCAStore
    • ECookieAttribute
    • EHttpAuthMethod
    • EHttpHeader
    • EHttpMethod
    • EUrlCode
    • EUrlPart

Random

    Core

    • Introduction
    • TRandom
  • Random.PRVHASH
  • Random.Secure
  • SFMT

    • Introduction
    • TSFMTRandom
  • Random.Squares
  • Random.Xoshiro

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType

Text

    CP932Encoding

    • Text.CP932Encoding

    CSV

    • Introduction
    • TCsvParser
    • TCsvHeader
    • TCsvRow
    • TCsvOptions
    • SCsvColumn

    Encoding

    • Text.Encoding

    Format

    • Introduction
    • TFormatter

    Graphviz

    • Introduction
    • TGVGraphviz
    • TAGraph

    Ini

    • Introduction
    • TIni
    • TIniProperty
    • TIniSection

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Markdown

    • Introduction
    • TMarkdown
    • IMDRenderer

    Pikchr

    • Introduction
    • EPikChrFlags

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    TOML

    • Introduction
    • ETomlNodeType
    • TToml
    • ITomlNode
    • STomlDate
    • STomlDateTime
    • STomlTime
    • TTomlArray
    • TTomlInteger
    • TTomlString
    • TTomlTable
    • TTomlBoolean

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute
Edit

BRL.Pixmap

Pixmaps provide storage for rectangular regions of pixels.

You can create a new pixmap using the CreatePixmap command, or load a pixmap using LoadPixmap.

Pixmaps have 5 properties: width, height, a byte pointer to the pixmap's pixels, pitch and format.

You can retrieve a pointer to a pixmap's pixels using the PixmapPixelPtr command.

A pixmap's pitch refers to the number of bytes between one row of pixels in the pixmap and the next. To retrieve a pixmap's pitch, use the PixmapPitch command.

A pixmap's pixel format determines how the pixels within a pixmap are stored in memory. This must be taken into account if you want to access pixels directly via a pixmap's pixel pointer. You can retrieve the format of a pixmap using the PixmapFormat command, and convert pixmaps from one format to another using ConvertPixmap.

You can also use ResizePixmap to resize a pixmap and flip a pixmap horizontally or vertically with XFlipPixmap and YFlipPixmap.

Types

TypeDescription
TPixmapThe Pixmap type
TPixmapLoaderAbstract base type for pixmap loaders

Functions

Function CreatePixmap:TPixmap( width:Int,height:Int,format:Int,align_bytes:Int=4 )

Create a pixmap

format should be one of the following:

FormatDescription
PF_A88 bit alpha
PF_I88 bit intensity
PF_RGB88824 bit big endian RGB
PF_BGR88824 bit little endian RGB
PF_RGBA888832 bit big endian RGB with alpha
PF_BGRA888832 bit little endian RGB with alpha

Note that the newly created pixmap will contain random data. ClearPixels can be used to set all pixels to a known value prior to use.

Returns

A new pixmap object of the specified width and height


Function CreateStaticPixmap:TPixmap( pixels:Byte Ptr,width:Int,height:Int,pitch:Int,format:Int )

Create a pixmap with existing pixel data

The memory referenced by a static pixmap is not released when the pixmap is deleted.

See CreatePixmap for valid pixmap formats.

Returns

A new pixmap object that references an existing block of memory


Function CopyPixmap:TPixmap( pixmap:TPixmap )

Copy a pixmap

Returns

A new pixmap object

Example

SuperStrict

Graphics 640 , 480

Local pix:TPixmap=LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")
If pix = Null Then
    RuntimeError ("Error Loading Image")
End If


Local newPix:TPixmap=CopyPixmap(pix)

Repeat
    Cls
    DrawPixmap pix, 50, 50
    DrawPixmap newPix, MouseX(), MouseY()
    Flip
Until KeyHit(key_escape) Or AppTerminate()


Function ConvertPixmap:TPixmap( pixmap:TPixmap,format:Int )

Convert pixel format of a pixmap

See CreatePixmap for valid pixmap formats.

Returns

A new pixmap object with the specified pixel format


Function PixmapWidth:Int( pixmap:TPixmap )

Get pixmap width

Returns

The width, in pixels, of pixmap

Example

SuperStrict

Graphics 640,480
Local pix:TPixmap=LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")

If pix = Null Then
    RuntimeError ("Error Loading Image")
End If

Repeat
    Cls
    ' Display Information
    DrawText "Image Width:"+PixmapWidth(pix)+"  Image Height:"+PixmapHeight(pix),0,0 

    DrawPixmap pix,100,100
    Flip
Until KeyHit(key_escape) Or AppTerminate()


Function PixmapHeight:Int( pixmap:TPixmap )

Get pixmap width

Returns

The height, in pixels, of pixmap

Example

SuperStrict

Graphics 640,480

Local pix:TPixmap = LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")

If pix = Null Then
    RuntimeError ("Error Loading Image")
End If

Repeat
    Cls
    
    ' Display Information
    DrawText "Image Width:"+PixmapWidth(pix)+"  Image Height:"+PixmapHeight(pix),0,0 

    DrawPixmap pix,100,100
    Flip
Until KeyHit(key_escape) Or AppTerminate()


Function PixmapPitch:Int( pixmap:TPixmap )

Get pixmap pitch

Pitch refers to the difference, in bytes, between the start of one row of pixels and the start of the next row.

Returns

The pitch, in bytes, of pixmap


Function PixmapFormat:Int( pixmap:TPixmap )

Get pixmap format

See CreatePixmap for supported formats.

Returns

The format of the pixels stored in pixmap


Function PixmapPixelPtr:Byte Ptr( pixmap:TPixmap,x:Int=0,y:Int=0 )

Get pixmap pixels

Returns

A byte pointer to the pixels stored in pixmap


Function PixmapWindow:TPixmap( pixmap:TPixmap,x:Int,y:Int,width:Int,height:Int )

Create a pixmap window

PixmapWindow creates a 'virtual' window into pixmap.

Returns

A new pixmap object


Function MaskPixmap:TPixmap( pixmap:TPixmap,mask_red:Int,mask_green:Int,mask_blue:Int ) NoDebug

Mask a pixmap

MaskPixmap builds a new pixmap with alpha components set to '0' wherever the pixel colors in the original pixmap match mask_red, mask_green and mask_blue. mask_red, mask_green and mask_blue should be in the range 0 to 255.

Returns

A new pixmap object


Function XFlipPixmap:TPixmap( pixmap:TPixmap )

Flip a pixmap horizontally

Returns

A new pixmap object

Example

SuperStrict

Graphics 640,480

Local pix:TPixmap=LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")

If pix = Null Then
    RuntimeError ("Error Loading Image")
End If

Repeat
    Cls
    DrawText "Press Key X or Y to change Orientation" , 10 , 10
    
    ' Change pixmap orientation
    If KeyHit(KEY_X) Then
        pix = XFlipPixmap(pix)
    End If
    
    If KeyHit(KEY_Y) Then
        pix = YFlipPixmap(pix)
    End If
    
    DrawPixmap pix,50,50
    Flip
Until KeyHit(key_escape) Or AppTerminate()


Function YFlipPixmap:TPixmap( pixmap:TPixmap ) NoDebug

Flip a pixmap vertically

Returns

A new pixmap object

Example

SuperStrict

Graphics 640,480

Local pix:TPixmap=LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")

If pix = Null Then
    RuntimeError ("Error Loading Image")
End If

Repeat
    Cls
    DrawText "Press Key X or Y to change Orientation" , 10 , 10
    
    ' Change pixmap orientation
    If KeyHit(KEY_X) Then
        pix = XFlipPixmap(pix)
    End If
    
    If KeyHit(KEY_Y) Then
        pix = YFlipPixmap(pix)
    End If
    
    DrawPixmap pix,50,50
    Flip
Until KeyHit(key_escape) Or AppTerminate()


Function ResizePixmap:TPixmap( pixmap:TPixmap,width:Int,height:Int )

Resize a pixmap

Returns

A new pixmap object of the specified width and height

Example

SuperStrict

Graphics 640 , 480

Local pix:TPixmap=LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")

If pix = Null Then
    RuntimeError ("Error Loading Image")
End If

'Reduce Image by 50%
Local newPix:TPixmap=ResizePixmap(pix, Int(PixmapWidth(pix)*.5), Int(PixmapHeight(pix)*.5))

Repeat
    Cls
    DrawPixmap pix, 50, 50
    DrawPixmap newPix, MouseX() , MouseY()
    Flip
Until KeyHit(key_escape) Or AppTerminate()


Function LoadPixmap:TPixmap( url:Object )

Load a pixmap

Returns

A pixmap object

Example 1

SuperStrict

Graphics 640,480
Local player:TPixmap=LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")

If player = Null Then
    RuntimeError ("Error Loading Image")
End If

Repeat
    Cls
    DrawPixmap Player,10,10
    Flip
Until KeyHit(key_escape) Or AppTerminate()

Example 2

SuperStrict

Graphics 640 , 480

Local pix:TPixmap=LoadPixmap(blitzmaxpath()+"\samples\hitoro\gfx\boing.png")
'converts Pixmap to Image
'note alpha transparency
Local image:TImage=LoadImage(pix)

Repeat
    Cls
    DrawPixmap pix, 50, 50
    DrawImage image, MouseX(), MouseY()
    Flip
Until KeyHit(key_escape) Or AppTerminate()


Function ReadPixel:Int( pixmap:TPixmap,x:Int,y:Int )

Read a pixel from a pixmap

The returned 32 bit value contains the following components:

bits 24-31pixel alpha
bits 16-23pixel red
bits 8-15pixel green
bits 0-7pixel blue

Returns

A 32 bit pixel value


Function WritePixel( pixmap:TPixmap,x:Int,y:Int,argb:Int )

Write a pixel to a pixmap

The 32 bit argb value contains the following components:

bits 24-31pixel alpha
bits 16-23pixel red
bits 8-15pixel green
bits 0-7pixel blue


Function ClearPixels( pixmap:TPixmap,argb:Int=0 )

Clear a pixmap

Sets all pixels in a pixmap to a 32 bit pixel value.

The 32 bit argb value contains the following components:

bits 24-31pixel alpha
bits 16-23pixel red
bits 8-15pixel green
bits 0-7pixel blue

Example

SuperStrict

Graphics 800 , 600

Local mypix:TPixmap = LoadPixmap(BlitzMaxPath()+"/samples/hitoro/gfx/boing.png")
If mypix = Null Then
    RuntimeError ("Error Loading Image")
End If

DrawPixmap mypix, 0, 0

ClearPixels(mypix, $FFFFFF)
 

DrawPixmap mypix, 300, 0

Flip

WaitKey


← TPathDirIteratorTPixmap →
  • Types
  • Functions
    • Function CreatePixmap:TPixmap( width:Int,height:Int,format:Int,align_bytes:Int=4 )
    • Function CreateStaticPixmap:TPixmap( pixels:Byte Ptr,width:Int,height:Int,pitch:Int,format:Int )
    • Function CopyPixmap:TPixmap( pixmap:TPixmap )
    • Function ConvertPixmap:TPixmap( pixmap:TPixmap,format:Int )
    • Function PixmapWidth:Int( pixmap:TPixmap )
    • Function PixmapHeight:Int( pixmap:TPixmap )
    • Function PixmapPitch:Int( pixmap:TPixmap )
    • Function PixmapFormat:Int( pixmap:TPixmap )
    • Function PixmapPixelPtr:Byte Ptr( pixmap:TPixmap,x:Int=0,y:Int=0 )
    • Function PixmapWindow:TPixmap( pixmap:TPixmap,x:Int,y:Int,width:Int,height:Int )
    • Function MaskPixmap:TPixmap( pixmap:TPixmap,mask_red:Int,mask_green:Int,mask_blue:Int ) NoDebug
    • Function XFlipPixmap:TPixmap( pixmap:TPixmap )
    • Function YFlipPixmap:TPixmap( pixmap:TPixmap ) NoDebug
    • Function ResizePixmap:TPixmap( pixmap:TPixmap,width:Int,height:Int )
    • Function LoadPixmap:TPixmap( url:Object )
    • Function ReadPixel:Int( pixmap:TPixmap,x:Int,y:Int )
    • Function WritePixel( pixmap:TPixmap,x:Int,y:Int,argb:Int )
    • Function ClearPixels( pixmap:TPixmap,argb:Int=0 )
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
Resources
More
GitHubStarChat on Discord
Copyright © 2026 Bruce A Henderson