@@ -73,6 +73,23 @@ public DirectBitmapImage(int width, int height)
7373 _bitmap = new WriteableBitmap ( width , height , 96 , 96 , PixelFormats . Bgra32 , null ) ;
7474 }
7575
76+ /// <summary>
77+ /// Constructs a DirectBitmapImage from a pixel array and width.
78+ /// Assumes BGRA32 format and calculates height automatically.
79+ /// </summary>
80+ /// <param name="bits">The pixel array (BGRA32).</param>
81+ /// <param name="width">The width of the image.</param>
82+ public DirectBitmapImage ( Pixel32 [ ] bits , int width )
83+ {
84+ if ( bits == null ) throw new ArgumentNullException ( nameof ( bits ) ) ;
85+ if ( width <= 0 ) throw new ArgumentOutOfRangeException ( nameof ( width ) ) ;
86+ if ( bits . Length % width != 0 ) throw new ArgumentException ( "Pixel array length must be divisible by width." ) ;
87+
88+ int height = bits . Length / width ;
89+ Bits = bits ;
90+ _bitmap = new WriteableBitmap ( width , height , 96 , 96 , PixelFormats . Bgra32 , null ) ;
91+ }
92+
7693 /// <summary>
7794 /// The height of the image.
7895 /// </summary>
@@ -153,7 +170,7 @@ public void SetPixelsUnsafe(IEnumerable<PixelData> pixels)
153170 /// Fills the bitmap with a uniform color using SIMD.
154171 /// </summary>
155172 /// <param name="color">The color to fill with.</param>
156- public unsafe void FillSimd ( Color color )
173+ public unsafe void FillSimd ( System . Drawing . Color color )
157174 {
158175 var packed = ( uint ) ( color . A << 24 | color . R << 16 | color . G << 8 | color . B ) ;
159176
0 commit comments