• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 12 رای - 2.25 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: سورس کد تبدیل عکس به ایکون ( سی شارپ )
حالت موضوعی
#1
Instructions: Assumes "using System.Drawing;"

Just paste into your code. Or make it public and put it in another class.

نقل قول: /// <summary>
/// Converts an image into an icon.
/// </summary>
/// <param name="img">The image that shall become an icon</param>
/// <param name="size">The width and height of the icon. Standard
/// sizes are 16x16, 32x32, 48x48, 64x64.</param>
/// <param name="keepAspectRatio">Whether the image should be squashed into a
/// square or whether whitespace should be put around it.</param>
/// <returns>An icon!!</returns>
private Icon MakeIcon(Image img, int size, bool keepAspectRatio) {
Bitmap square = new Bitmap(size, size); // create new bitmap
Graphics g = Graphics.FromImage(square); // allow drawing to it

int x, y, w, h; // dimensions for new image

if(!keepAspectRatio || img.Height == img.Width) {
// just fill the square
x = y = 0; // set x and y to 0
w = h = size; // set width and height to size
} else {
// work out the aspect ratio
float r = (float)img.Width / (float)img.Height;

// set dimensions accordingly to fit inside size^2 square
if(r > 1) { // w is bigger, so divide h by r
w = size;
h = (int)((float)size / r);
x = 0; y = (size - h) / 2; // center the image
} else { // h is bigger, so multiply w by r
w = (int)((float)size * r);
h = size;
y = 0; x = (size - w) / 2; // center the image
}
}

// make the image shrink nicely by using HighQualityBicubic mode
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(img, x, y, w, h); // draw image with specified dimensions
g.Flush(); // make sure all drawing operations complete before we get the icon

// following line would work directly on any image, but then
// it wouldn't look as nice.
return Icon.FromHandle(square.GetHicon());
}
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
#2
accutane tabletten kaufen accutane ohne rezept isotretinoin 20mg rezeptfrei
accutane kaufen deutschland accutane tabletten kaufen accutane rezeptfrei bestellen
accutane kaufen deutschland accutane tabletten kaufen isotretinoin rezeptfrei österreich
isotretinoin ohne rezept kaufen accutane tabletten kaufen isotretinoin rezeptfrei kaufen
accutane rezeptfrei accutane tabletten kaufen isotretinoin ohne rezept kaufen
accutane kaufen schweiz accutane tabletten kaufen accutane online kaufen
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کد تبدیل عکس رنگی به سیاه سفید (سی شارپ) Amin_Mansouri 1 7,223 10-08-2022، 08:06 PM
آخرین ارسال: sonusood
  سورس کد تغییر دادن سایز عکس ( سی شارپ) Amin_Mansouri 1 6,778 10-08-2022، 07:08 PM
آخرین ارسال: sonusood
  سورس کد ساخت فایل pdf (سی شارپ) Amin_Mansouri 3 12,081 07-01-2017، 10:05 AM
آخرین ارسال: 7seo
  کد ssim در سی شارپ saraj00n 4 5,838 05-22-2017، 04:33 PM
آخرین ارسال: delsanik91
  سورس کد الگوریتم رمزنگاری تصویر زهرا ترکاشوند 3 9,369 05-17-2016، 01:41 PM
آخرین ارسال: mehdisadeghi
  سورس کد ifc saraj00n 1 3,672 05-13-2016، 01:46 PM
آخرین ارسال: saraj00n
  کد سی شارپ Save,SaveAs razi0tn 0 3,784 01-19-2016، 02:53 PM
آخرین ارسال: razi0tn
  سورس کد اضافه ,ویرایش,حذف,جستجو در دیتابیس(سی شارپ) Amin_Mansouri 6 24,099 12-09-2015، 08:17 AM
آخرین ارسال: Amin_Mansouri
  فروش سورس کد کتابساز اندروید دانشجو omid_student 1 4,698 08-12-2014، 11:00 AM
آخرین ارسال: Amin_Mansouri
  تبدیل عکس jpg به فرمت jpeg وبلعکس Sanazjoon 1 4,146 05-12-2014، 08:15 PM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان