午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    C#根據(jù)大圖片生成高清縮略圖
    來源:易賢網(wǎng) 閱讀:2320 次 日期:2014-08-20 15:14:11
    溫馨提示:易賢網(wǎng)小編為您整理了“C#根據(jù)大圖片生成高清縮略圖”,方便廣大網(wǎng)友查閱!

    C#生成高清縮略圖代碼,一個C#函數(shù)模塊,內(nèi)含注釋,后附函數(shù)參數(shù),下面來看這個C#生成縮略圖代碼:

    01public static void SetGoodImage(string fileName, string newFile, int maxHeight, int maxWidth,long qualitys)

    02{

    03 if (qualitys == 0)

    04 {

    05 qualitys = 80;

    06 }

    07 using (System.Drawing.Image img = System.Drawing.Image.FromFile(fileName))

    08 {

    09 System.Drawing.Imaging.ImageFormat

    10 thisFormat = img.RawFormat;

    11 Size newSize = NewSize(maxWidth, maxHeight, img.Width, img.Height);

    12 Bitmap outBmp = new Bitmap(newSize.Width, newSize.Height);

    13 Graphics g = Graphics.FromImage(outBmp);

    14 // 設(shè)置畫布的描繪質(zhì)量

    15 g.CompositingQuality = CompositingQuality.HighQuality;

    16 g.SmoothingMode = SmoothingMode.HighQuality;

    17 g.InterpolationMode = InterpolationMode.HighQualityBicubic;

    18 g.DrawImage(img, new Rectangle(0, 0, newSize.Width, newSize.Height),

    19 0, 0, img.Width, img.Height, GraphicsUnit.Pixel);

    20 g.Dispose();

    21 // 以下代碼為保存圖片時,設(shè)置壓縮質(zhì)量

    22 EncoderParameters encoderParams = new EncoderParameters();

    23 long[] quality = new long[1];

    24 quality[0] = qualitys;

    25 EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);

    26 encoderParams.Param[0] = encoderParam;

    27 //獲得包含有關(guān)內(nèi)置圖像編碼解碼器的信息的ImageCodecInfo 對象.

    28 ImageCodecInfo[] arrayICI = ImageCodecInfo.GetImageEncoders();

    29 ImageCodecInfo jpegICI = null;

    30 for (int x = 0;

    31 x < arrayICI.Length;

    32 x++)

    33 {

    34 if (arrayICI[x].FormatDescription.Equals("JPEG"))

    35 {

    36 jpegICI = arrayICI[x];

    37 //設(shè)置JPEG編碼

    38 break;

    39 }

    40 }

    41 if (jpegICI != null)

    42 {

    43 outBmp.Save(newFile, jpegICI, encoderParams);

    44 }

    45 else

    46 {

    47 outBmp.Save(newFile, thisFormat);

    48 }

    49 img.Dispose();

    50 outBmp.Dispose();

    51 }

    52}

    函數(shù)參數(shù)說明:

    view sourceprint?1/// 原文件

    2/// 新文件

    3/// 最大高度

    4/// 最大寬度

    5/// 質(zhì)量,如果為0,則設(shè)為80

    更多信息請查看IT技術(shù)專欄

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機網(wǎng)站地址:C#根據(jù)大圖片生成高清縮略圖
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2025國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)