|
|
@ -108,37 +108,15 @@ namespace CameraCard
|
|
|
|
|
|
|
|
|
|
|
|
private void shotBtn_Click(object sender, EventArgs e)
|
|
|
|
private void shotBtn_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var bitmap = this.ClipImage();
|
|
|
|
using (var bitmap = (this.cameraRender.Image.Clone() as Image))
|
|
|
|
bitmap = this.ResizeImage(bitmap);
|
|
|
|
|
|
|
|
this.photo.Image?.Dispose();
|
|
|
|
|
|
|
|
this.photo.Image = bitmap;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Bitmap ClipImage()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var image = this.cameraRender.Image;
|
|
|
|
|
|
|
|
var width = this._rect.Width * image.Width / this.cameraRender.Width;
|
|
|
|
|
|
|
|
var height = this._rect.Height * width / this._rect.Width;
|
|
|
|
|
|
|
|
var bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
|
|
|
|
|
|
|
|
bitmap.SetResolution(350, 350);
|
|
|
|
|
|
|
|
using (var g = Graphics.FromImage(bitmap))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
|
|
using (var bitmap2 = bitmap.ClipImage(this.cameraRender.Width, this.cameraRender.Height, this._rectWidth, this._rectHeight))
|
|
|
|
g.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle((image.Width - bitmap.Width) / 2, (image.Height - bitmap.Height) / 2, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
this.photo.Image?.Dispose();
|
|
|
|
return bitmap;
|
|
|
|
this.photo.Image = bitmap2.ResizeImage(this._photoWidth, this._photoHeight);
|
|
|
|
}
|
|
|
|
var base64Value = $"data:image/jpeg;base64,{this.photo.Image.ToBase64()}";
|
|
|
|
|
|
|
|
}
|
|
|
|
private Bitmap ResizeImage(Bitmap image)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var bitmap = new Bitmap(this._photoWidth, this._photoHeight, PixelFormat.Format24bppRgb);
|
|
|
|
|
|
|
|
bitmap.SetResolution(350, 350);
|
|
|
|
|
|
|
|
using (var g = Graphics.FromImage(bitmap))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
|
|
|
|
|
|
g.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bitmap;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateIdCardUI(IdCardModel model)
|
|
|
|
private void UpdateIdCardUI(IdCardModel model)
|
|
|
|