mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Fix winforms compile
This commit is contained in:
parent
938a15b378
commit
4431f87525
@ -29,7 +29,7 @@ public class MacEtoPlatform : EtoPlatform
|
||||
return new Bitmap(new BitmapHandler(nsImage));
|
||||
}
|
||||
|
||||
public override IMemoryImage DrawHourglass(IMemoryImage image)
|
||||
public override IMemoryImage DrawHourglass(ImageContext imageContext, IMemoryImage image)
|
||||
{
|
||||
// TODO
|
||||
return image;
|
||||
|
@ -72,14 +72,15 @@ public class WinFormsDesktopForm : DesktopForm
|
||||
|
||||
protected override void SetThumbnailSpacing(int thumbnailSize)
|
||||
{
|
||||
_listView.NativeControl.Padding = new Padding(0, 20, 0, 0);
|
||||
var nativeControl = ((WinFormsListView<UiImage>) _listView).NativeControl;
|
||||
nativeControl.Padding = new wf.Padding(0, 20, 0, 0);
|
||||
const int MIN_PADDING = 6;
|
||||
const int MAX_PADDING = 66;
|
||||
// Linearly scale the padding with the thumbnail size
|
||||
int padding = MIN_PADDING + (MAX_PADDING - MIN_PADDING) * (thumbnailSize - ThumbnailSizes.MIN_SIZE) /
|
||||
(ThumbnailSizes.MAX_SIZE - ThumbnailSizes.MIN_SIZE);
|
||||
int spacing = thumbnailSize + padding * 2;
|
||||
WinFormsHacks.SetListSpacing(_listView.NativeControl, spacing, spacing);
|
||||
WinFormsHacks.SetListSpacing(nativeControl, spacing, spacing);
|
||||
}
|
||||
|
||||
protected override void CreateToolbarButton(Command command)
|
||||
|
@ -49,7 +49,7 @@ public class WinFormsEtoPlatform : EtoPlatform
|
||||
return ((GdiImage) image).Bitmap.ToEto();
|
||||
}
|
||||
|
||||
public override IMemoryImage DrawHourglass(IMemoryImage image)
|
||||
public override IMemoryImage DrawHourglass(ImageContext imageContext, IMemoryImage image)
|
||||
{
|
||||
var bitmap = new System.Drawing.Bitmap(image.Width, image.Height);
|
||||
using (var g = sd.Graphics.FromImage(bitmap))
|
||||
@ -71,6 +71,6 @@ public class WinFormsEtoPlatform : EtoPlatform
|
||||
g.DrawImage(hourglass, new sd.Rectangle((bitmap.Width - 32) / 2, (bitmap.Height - 32) / 2, 32, 32));
|
||||
}
|
||||
image.Dispose();
|
||||
return new GdiImage(bitmap);
|
||||
return new GdiImage(imageContext, bitmap);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using NAPS2.EtoForms;
|
||||
using NAPS2.EtoForms.Ui;
|
||||
using NAPS2.EtoForms.WinForms;
|
||||
using NAPS2.Images.Gdi;
|
||||
using NAPS2.ImportExport;
|
||||
using NAPS2.ImportExport.Pdf;
|
||||
using NAPS2.Scan;
|
||||
|
@ -125,9 +125,12 @@ internal static class TwainApi
|
||||
{
|
||||
int bitcount = 0;
|
||||
|
||||
// TODO: Clean this up a bit
|
||||
using Bitmap bmp = DibUtils.BitmapFromDib(img, out bitcount);
|
||||
Bitmaps.Add(_scanningContext.CreateProcessedImage(new GdiImage(bmp), bitcount == 1 ? BitDepth.BlackAndWhite : BitDepth.Color, _settings.MaxQuality, _settings.Quality));
|
||||
var bitDepth = bitcount == 1 ? BitDepth.BlackAndWhite : BitDepth.Color;
|
||||
using var storage = new GdiImage(_scanningContext.ImageContext, bmp);
|
||||
var image = _scanningContext.CreateProcessedImage(
|
||||
storage, bitDepth, _settings.MaxQuality, _settings.Quality);
|
||||
Bitmaps.Add(image);
|
||||
}
|
||||
_form.Close();
|
||||
break;
|
||||
|
@ -16,5 +16,5 @@ public abstract class EtoPlatform
|
||||
public abstract IListView<T> CreateListView<T>(ListViewBehavior<T> behavior) where T : notnull;
|
||||
public abstract void ConfigureImageButton(Button button);
|
||||
public abstract Bitmap ToBitmap(IMemoryImage image);
|
||||
public abstract IMemoryImage DrawHourglass(IMemoryImage thumb);
|
||||
public abstract IMemoryImage DrawHourglass(ImageContext imageContext, IMemoryImage thumb);
|
||||
}
|
@ -30,7 +30,7 @@ public class UiThumbnailProvider
|
||||
}
|
||||
if (img.IsThumbnailDirty)
|
||||
{
|
||||
thumb = EtoPlatform.Current.DrawHourglass(thumb);
|
||||
thumb = EtoPlatform.Current.DrawHourglass(_imageContext, thumb);
|
||||
}
|
||||
return thumb;
|
||||
}
|
||||
@ -46,7 +46,7 @@ public class UiThumbnailProvider
|
||||
}
|
||||
_placeholder?.Dispose();
|
||||
_placeholder = _imageContext.Create(thumbnailSize, thumbnailSize, ImagePixelFormat.RGB24);
|
||||
_placeholder = EtoPlatform.Current.DrawHourglass(_placeholder);
|
||||
_placeholder = EtoPlatform.Current.DrawHourglass(_imageContext, _placeholder);
|
||||
return _placeholder;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user