private static void DoSaveWidePlatformDependent(IAsyncContext context, IBitmapDataInternal bitmapData, Rectangle rect, BinaryWriter writer) { PixelFormat pixelFormat = bitmapData.PixelFormat; int byteLength = pixelFormat.ToBitsPerPixel() >> 3; // using a temp 1x1 managed bitmap data for the conversion using IBitmapDataInternal tempData = CreateManagedBitmapData(new Size(1, 1), pixelFormat, bitmapData.BackColor, bitmapData.AlphaThreshold); IBitmapDataRowInternal tempRow = tempData.DoGetRow(0); IBitmapDataRowInternal row = bitmapData.DoGetRow(rect.Top); for (int y = 0; y < rect.Height; y++) { if (context.IsCancellationRequested) { return; } for (int x = rect.Left; x < rect.Right; x++) { tempRow.DoSetColor32(0, row.DoGetColor32(x)); for (int i = 0; i < byteLength; i++) { writer.Write(tempRow.DoReadRaw <byte>(i)); } } row.MoveNextRow(); context.Progress?.Increment(); } }
private static void DoSaveRawLongs(IAsyncContext context, IBitmapDataInternal bitmapData, Rectangle rect, BinaryWriter writer) { IBitmapDataRowInternal row = bitmapData.DoGetRow(rect.Top); for (int y = 0; y < rect.Height; y++) { if (context.IsCancellationRequested) { return; } for (int x = rect.Left; x < rect.Right; x++) { writer.Write(row.DoReadRaw <long>(x)); } row.MoveNextRow(); context.Progress?.Increment(); } }