@ -39,12 +39,14 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
}
}
BitmapData data = bmp . LockBits ( fullRect , ImageLockMode . ReadWrite , bmp . PixelFormat ) ;
BitmapData data = bmp . LockBits ( fullRect , ImageLockMode . ReadWrite , bmp . PixelFormat ) ;
var image = new Image < TPixel > ( w , h ) ;
try
{
byte * sourcePtrBase = ( byte * ) data . Scan0 ;
byte * sourcePtrBase = ( byte * ) data . Scan0 ;
long sourceRowByteCount = data . Stride ;
long sourceRowByteCount = data . Stride ;
long destRowByteCount = w * sizeof ( Bgra32 ) ;
long destRowByteCount = w * sizeof ( Bgra32 ) ;
var image = new Image < TPixel > ( w , h ) ;
Configuration configuration = image . GetConfiguration ( ) ;
Configuration configuration = image . GetConfiguration ( ) ;
using ( IMemoryOwner < Bgra32 > workBuffer = Configuration . Default . MemoryAllocator . Allocate < Bgra32 > ( w ) )
using ( IMemoryOwner < Bgra32 > workBuffer = Configuration . Default . MemoryAllocator . Allocate < Bgra32 > ( w ) )
@ -65,6 +67,11 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
}
}
}
}
}
}
}
finally
{
bmp . UnlockBits ( data ) ;
}
return image ;
return image ;
}
}
@ -91,12 +98,14 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
}
}
BitmapData data = bmp . LockBits ( fullRect , ImageLockMode . ReadWrite , bmp . PixelFormat ) ;
BitmapData data = bmp . LockBits ( fullRect , ImageLockMode . ReadWrite , bmp . PixelFormat ) ;
var image = new Image < TPixel > ( w , h ) ;
try
{
byte * sourcePtrBase = ( byte * ) data . Scan0 ;
byte * sourcePtrBase = ( byte * ) data . Scan0 ;
long sourceRowByteCount = data . Stride ;
long sourceRowByteCount = data . Stride ;
long destRowByteCount = w * sizeof ( Bgr24 ) ;
long destRowByteCount = w * sizeof ( Bgr24 ) ;
var image = new Image < TPixel > ( w , h ) ;
Configuration configuration = image . GetConfiguration ( ) ;
Configuration configuration = image . GetConfiguration ( ) ;
using ( IMemoryOwner < Bgr24 > workBuffer = Configuration . Default . MemoryAllocator . Allocate < Bgr24 > ( w ) )
using ( IMemoryOwner < Bgr24 > workBuffer = Configuration . Default . MemoryAllocator . Allocate < Bgr24 > ( w ) )
@ -110,14 +119,15 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
byte * sourcePtr = sourcePtrBase + ( data . Stride * y ) ;
byte * sourcePtr = sourcePtrBase + ( data . Stride * y ) ;
Buffer . MemoryCopy ( sourcePtr , destPtr , destRowByteCount , sourceRowByteCount ) ;
Buffer . MemoryCopy ( sourcePtr , destPtr , destRowByteCount , sourceRowByteCount ) ;
PixelOperations < TPixel > . Instance . FromBgr24 (
PixelOperations < TPixel > . Instance . FromBgr24 ( configuration , workBuffer . GetSpan ( ) . Slice ( 0 , w ) , row ) ;
configuration ,
workBuffer . GetSpan ( ) . Slice ( 0 , w ) ,
row ) ;
}
}
}
}
}
}
}
finally
{
bmp . UnlockBits ( data ) ;
}
return image ;
return image ;
}
}
@ -131,6 +141,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
var resultBitmap = new Bitmap ( w , h , PixelFormat . Format32bppArgb ) ;
var resultBitmap = new Bitmap ( w , h , PixelFormat . Format32bppArgb ) ;
var fullRect = new Rectangle ( 0 , 0 , w , h ) ;
var fullRect = new Rectangle ( 0 , 0 , w , h ) ;
BitmapData data = resultBitmap . LockBits ( fullRect , ImageLockMode . ReadWrite , resultBitmap . PixelFormat ) ;
BitmapData data = resultBitmap . LockBits ( fullRect , ImageLockMode . ReadWrite , resultBitmap . PixelFormat ) ;
try
{
byte * destPtrBase = ( byte * ) data . Scan0 ;
byte * destPtrBase = ( byte * ) data . Scan0 ;
long destRowByteCount = data . Stride ;
long destRowByteCount = data . Stride ;
@ -150,8 +162,11 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
}
}
}
}
}
}
}
finally
{
resultBitmap . UnlockBits ( data ) ;
resultBitmap . UnlockBits ( data ) ;
}
return resultBitmap ;
return resultBitmap ;
}
}