将照片转换为护照尺寸(当我在Windows应用程序中上传图片时自动裁剪) [英] convert a photo into passport size(Auto crop when i upload a picture in Windows application)

查看:924
本文介绍了将照片转换为护照尺寸(当我在Windows应用程序中上传图片时自动裁剪)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可以上传照片的软件,但是我无法缩小照片的大小
自动转换为护照尺寸分辨率

I have software that is possible to upload a photo but i can''t reduce the size of photo
automatically into passport size resolution

推荐答案

尝试:
/// <summary>
/// Create a thumbnail image.
/// </summary>
/// <param name="path">path to full size image</param>
/// <param name="width">Width of thumbnail</param>
/// <param name="height">Height of thumbnail</param>
public static Image GetThumbnailImage(string path, int width, int height)
    {
    using (Image image = Image.FromFile(path))
        {
        Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
        return image.GetThumbnailImage(width, height, myCallback, IntPtr.Zero);
        }
    }


/// <summary>
/// This is not used in GDI+ 1.0, but must be supplied to some GDI calls.
/// E.g. Image.GetThumbnailImage
/// </summary>
/// <returns>false always</returns>
private static bool ThumbnailCallback()
    {
    return false;
    }


这篇关于将照片转换为护照尺寸(当我在Windows应用程序中上传图片时自动裁剪)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆