高品質でスペースの小さいサムネイルを生成するための C# コード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.IO; namespace ConsoleApplication3_ThumbnailImg { class Program { const int HEIGHT = 190; const int WIDTH = 190; static void Main(string[] args) { string srcImgPath = @"G:\photoes\20060725\Picture 057.jpg"; string targetFolder = @"E:\Diary\Test\thumbnail"; SetThumbnail_1(srcImgPath, targetFolder); SetThumbnail_2(srcImgPath, targetFolder); SetThumbnail_3(srcImgPath, targetFolder); Console.Read(); } static void SetThumbnail_1(string srcImgPath, string targetFolder) { using (Bitmap source = new Bitmap(srcImgPath)) { // return the source image if it's smaller than the designated thumbnail int wi, hi; wi = WIDTH; hi = HEIGHT; // maintain the aspect ratio despite the thumbnail size parameters if (source.Width > source.Height) { wi = WIDTH; hi = (int)(source.Height * ((decimal)WIDTH / source.Width)); } else { hi = HEIGHT; wi = (int)(source.Width * ((decimal)HEIGHT / source.Height)); } using (Image thumb = source.GetThumbnailImage(wi, hi, null, IntPtr.Zero)) { string targetPath = Path.Combine(targetFolder, "th_1.jpg"); thumb.Save(targetPath); } } } static void SetThumbnail_2(string srcImgPath, string targetFolder) { using (Bitmap source = new Bitmap(srcImgPath)) { // return the source image if it's smaller than the designated thumbnail int wi, hi; wi = WIDTH; hi = HEIGHT; // maintain the aspect ratio despite the thumbnail size parameters if (source.Width > source.Height) { wi = WIDTH; hi = (int)(source.Height * ((decimal)WIDTH / source.Width)); } else { hi = HEIGHT; wi = (int)(source.Width * ((decimal)HEIGHT / source.Height)); } // original code that creates lousy thumbnails // System.Drawing.Image ret = source.GetThumbnailImage(wi,hi,null,IntPtr.Zero); using (System.Drawing.Bitmap thumb = new Bitmap(wi, hi)) { using (Graphics g = Graphics.FromImage(thumb)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.FillRectangle(Brushes.White, 0, 0, wi, hi); g.DrawImage(source, 0, 0, wi, hi); } string targetPath = Path.Combine(targetFolder, "th_2.jpg"); thumb.Save(targetPath); } } } static void SetThumbnail_3(string srcImgPath, string targetFolder) { //Configure JPEG Compression Engine System.Drawing.Imaging.EncoderParameters encoderParams = new System.Drawing.Imaging.EncoderParameters(); long[] quality = new long[1]; quality[0] = 75; System.Drawing.Imaging.EncoderParameter encoderParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality); encoderParams.Param[0] = encoderParam; System.Drawing.Imaging.ImageCodecInfo[] arrayICI = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders(); System.Drawing.Imaging.ImageCodecInfo jpegICI = null; for (int x = 0; x < arrayICI.Length; x++) { if (arrayICI[x].FormatDescription.Equals("JPEG")) { jpegICI = arrayICI[x]; break; } } using (Bitmap source = new Bitmap(srcImgPath)) { int wi, hi; wi = WIDTH; hi = HEIGHT; // maintain the aspect ratio despite the thumbnail size parameters if (source.Width > source.Height) { wi = WIDTH; hi = (int)(source.Height * ((decimal)WIDTH / source.Width)); } else { hi = HEIGHT; wi = (int)(source.Width * ((decimal)HEIGHT / source.Height)); } // original code that creates lousy thumbnails // System.Drawing.Image ret = source.GetThumbnailImage(wi,hi,null,IntPtr.Zero); using (System.Drawing.Bitmap thumb = new Bitmap(wi, hi)) { using (Graphics g = Graphics.FromImage(thumb)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.FillRectangle(Brushes.White, 0, 0, wi, hi); g.DrawImage(source, 0, 0, wi, hi); } string targetPath = Path.Combine(targetFolder, "th_3.jpg"); thumb.Save(targetPath, jpegICI, encoderParams); } } } } }

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









C言語では、以下などのエスケープシーケンスを通じて特殊文字が処理されます。\ nはラインブレークを表します。 \ tはタブ文字を意味します。 ESACEシーケンスまたは文字定数を使用して、Char C = '\ n'などの特殊文字を表します。バックスラッシュは2回逃げる必要があることに注意してください。さまざまなプラットフォームとコンパイラが異なるエスケープシーケンスを持っている場合があります。ドキュメントを参照してください。

Cでは、文字列でCharタイプが使用されます。1。単一の文字を保存します。 2。配列を使用して文字列を表し、ヌルターミネーターで終了します。 3。文字列操作関数を介して動作します。 4.キーボードから文字列を読み取りまたは出力します。

C言語では、charとwchar_tの主な違いは文字エンコードです。CharはASCIIを使用するか、ASCIIを拡張し、WCHAR_TはUnicodeを使用します。 Charは1〜2バイトを占め、WCHAR_Tは2〜4バイトを占有します。 charは英語のテキストに適しており、wchar_tは多言語テキストに適しています。 CHARは広くサポートされており、WCHAR_TはコンパイラとオペレーティングシステムがUnicodeをサポートするかどうかに依存します。 CHARの文字範囲は限られており、WCHAR_Tの文字範囲が大きく、特別な機能が算術演算に使用されます。

c言語のシンボルの使用方法は、算術、割り当て、条件、ロジック、ビット演算子などをカバーします。算術演算子は基本的な数学的操作に使用されます。割り当てと追加、下位、乗算、除算の割り当てには、条件操作に使用されます。ポインター、ファイル終了マーカー、および非数値値。

マルチスレッドと非同期の違いは、マルチスレッドが複数のスレッドを同時に実行し、現在のスレッドをブロックせずに非同期に操作を実行することです。マルチスレッドは計算集約型タスクに使用されますが、非同期はユーザーインタラクションに使用されます。マルチスレッドの利点は、コンピューティングのパフォーマンスを改善することですが、非同期の利点はUIスレッドをブロックしないことです。マルチスレッドまたは非同期を選択することは、タスクの性質に依存します。計算集約型タスクマルチスレッド、外部リソースと相互作用し、UIの応答性を非同期に使用する必要があるタスクを使用します。

C言語では、charタイプの変換は、キャスト:キャスト文字を使用することにより、別のタイプに直接変換できます。自動タイプ変換:あるタイプのデータが別のタイプの値に対応できる場合、コンパイラは自動的に変換します。

C言語に組み込みの合計機能はないため、自分で書く必要があります。合計は、配列を通過して要素を蓄積することで達成できます。ループバージョン:合計は、ループとアレイの長さを使用して計算されます。ポインターバージョン:ポインターを使用してアレイ要素を指し示し、効率的な合計が自己概要ポインターを通じて達成されます。アレイバージョンを動的に割り当てます:[アレイ]を動的に割り当ててメモリを自分で管理し、メモリの漏れを防ぐために割り当てられたメモリが解放されます。

Char Arrayは文字シーケンスをC言語で保存し、char array_name [size]として宣言されます。アクセス要素はサブスクリプト演算子に渡され、要素は文字列のエンドポイントを表すnullターミネーター「\ 0」で終了します。 C言語は、strlen()、strcpy()、strcat()、strcmp()など、さまざまな文字列操作関数を提供します。
