So, I pulled from my archives pieces I developed while making a product I called Vinny. Vinny was written shortly after my son Vinny passed away... I was actively working with Boyertown PA Fire Department - where I learned most of the Volunteer Fire Departments were running pirated Adobe Photoshop. So... Vinny consisted of pre-defined "Photo Improvement" routines. Allowing my Department customers to touch-up photos with preset functions. Long story short (well as short as I can manage), I had build some extremely fast pixel level graphics. An area where GDI+ is weak.
Introducing DXDGI++ "Pixel Level" Components
This TDXPixelBuffer class provides the core foundation for high-performance pixel operations. Here are the key features it delivers:DXGDI++ High-Performance Pixel Buffer & Bitmap Manager
Part of the DXGDI++ Graphics Library
TDXPixelBuffer provides low-level, high-performance pixel manipulation capabilities
including direct memory access, efficient blitting, and optimized pixel
operations that exceed the performance of standard GDI+ for pixel-level work.
Key Features:
Direct Memory Access: Raw pointer access with GetRawData() and GetDataPtr()
Thread-Safe Locking: RAII-style locking with TDXPixelBufferLock
Multiple Pixel Formats: Support for ARGB32, RGB24, RGB16, etc.
Optimized Memory Layout: 4-byte aligned scan lines for better SIMD performance
High-Performance Pixel Access: Inline methods for locked access
Memory Management Options: Managed memory, external memory, or memory-mapped files
Bulk Operations: Clear(), FillRect(), CopyFrom() with optimized implementations
Usage: Next area of focus is:
Key Features:DXGDIPlusBlitter - Optimized Blitting and Drawing Engine.
Part of the DXGDI++ Graphics Library
DXGDIPlusBlitter provides lightning-fast image transfers and drawing operations that work with our TDXPixelBuffer.
Direct Memory Access: Works directly with pixel buffer memory
Optimized Algorithms: Uses Bresenham and other efficient rasterization algorithms
Minimal Allocations: Reuses buffers and avoids temporary object creation
SIMD-Ready: Structure designed for easy SIMD optimization additions
Lock Management: Proper buffer locking prevents race conditions
Key Features:DXGDI++ Advanced Alpha Blending & Compositing Engine
Part of the DXGDI++ Graphics Library
DXGDIPlusAlphaCompositor provides highly optimized functions for various alpha blending
and compositing modes, leveraging direct pixel buffer access. It supports
standard alpha blending, complex blend modes, and handling of pre-multiplied
alpha for accurate and fast compositing.
Extensive Blend Modes: Implements a wide array of Photoshop-like blend modes (Normal, Add, Multiply, Screen, Overlay, Darken, Lighten, Difference, etc.) for ARGB32 pixels.
Optimized PixelBlend Functions: Each blend mode has a dedicated PixelBlend function that performs the raw ARGB32 calculation, designed for efficiency using bitwise operations and integer math.
Span-Based Blending (BlendSpanARGB32): The BlendSpanARGB32 method orchestrates the per-pixel blend functions over an entire horizontal line (span) of pixels. This is a common optimization strategy to reduce loop overhead.
Buffer Composition (Compose): The Compose method allows you to combine an entire SrcBuffer onto a DestBuffer at a specified position, using any of the available blend modes and a global alpha value. It handles clipping automatically.
Pre-multiplied Alpha Support: Includes ConvertToPremultipliedAlpha and ConvertFromPremultipliedAlpha to correctly handle pre-multiplied alpha values, which are essential for physically accurate and artifact-free compositing, especially when dealing with transparency.
Alpha Masking (ApplyAlphaMask): A function to apply an 8-bit grayscale (A8) mask to an ARGB32 destination buffer, letting you control the transparency of regions based on a separate image.
Direct TDXPixelBuffer Integration: Seamlessly works with the TDXPixelBuffer class, leveraging its direct memory access and locking mechanisms.
Usage: