Overview
LibGfx provides essential graphics functionality:- Bitmap Operations: Image creation, loading, and manipulation
- Color Management: RGB, HSV, YUV, Oklab color spaces
- 2D Rendering: Shapes, lines, gradients, and anti-aliasing
- Font Rendering: TrueType, bitmap fonts, and text layout
- Image Codecs: PNG, JPEG, GIF, BMP, and more
- Transformations: Affine transformations and scaling
Core Types
Bitmap
The fundamental image representation.Raster image data with multiple pixel formats.
Bitmap Formats
Pixel Formats
Pixel Formats
Pixel Access
Read pixel color at coordinates.
Set pixel color at coordinates.
Direct scanline access for performance.
Color Management
Color Class
32-bit ARGB color with extensive color space support.
Color Spaces
HSV Color Space
HSV Color Space
YUV Color Space
YUV Color Space
Oklab Color Space
Oklab Color Space
Color Operations
Alpha blend two colors.
Interpolate between colors.
Calculate perceived brightness.
WCAG contrast ratio calculation.
Painter
The main 2D rendering interface.2D drawing operations on bitmaps.
Shape Drawing
Basic Shapes
Basic Shapes
Gradient Fills
Gradient Types
Gradient Types
Line Drawing
Draw a line between two points.Line Styles:
LineStyle::Solid: Continuous lineLineStyle::Dotted: Dotted patternLineStyle::Dashed: Dashed pattern
Bezier Curves
Curve Drawing
Curve Drawing
Bitmap Operations
Blitting
Copy bitmap data with alpha blending.
Draw bitmap with scaling.Scaling Modes:
NearestNeighbor: Fast, pixelatedBilinearBlend: Smooth interpolationSmoothPixels: High-quality scaling
Transformations
Bitmap Transformations
Bitmap Transformations
Font Rendering
Abstract font interface for text rendering.
Text Drawing
Text Rendering
Text Rendering
TopLeft,TopCenter,TopRightCenterLeft,Center,CenterRightBottomLeft,BottomCenter,BottomRight
None: No elisionRight: Add ellipsis at end
DontWrap: Single lineWrap: Multi-line wrapping
Image Format Support
LibGfx includes loaders for many image formats:Supported Formats:
- Raster: PNG, JPEG, GIF, BMP, TGA, TIFF, WebP
- Advanced: JPEG2000, JBIG2, JXL (JPEG XL)
- Other: QOI, IFF/LBM, DDS, ICO
- Portable: PBM, PGM, PPM, PAM
- Vector: TVG (TinyVG)
Advanced Features
Anti-Aliasing
High-quality anti-aliased rendering.Location:
LibGfx/AntiAliasingPainter.hAffine Transformations
2D Transforms
2D Transforms
LibGfx/AffineTransform.hColor Utilities
Color Manipulation
Color Manipulation
Geometry Types
LibGfx provides geometric primitives:
IntPoint,FloatPoint: 2D pointsIntSize,FloatSize: DimensionsIntRect,FloatRect: RectanglesLine: Line segmentsTriangle: 2D trianglesPath: Complex vector paths
Style Painting
Classic UI widget rendering.Provides themed drawing for:
- Buttons (normal, pressed, disabled)
- Checkboxes and radio buttons
- Progress bars
- Tabs and frames
LibGfx/ClassicStylePainter.hSource Location
Directory:Userland/Libraries/LibGfx/
Key Files:
Bitmap.h: Core bitmap functionalityColor.h: Color representation and manipulationPainter.h: 2D rendering operationsFont/Font.h: Font interface and renderingAffineTransform.h: 2D transformationsAntiAliasingPainter.h: Anti-aliased drawing
