Click here to Skip to main content
15,891,529 members
Home / Discussions / C#
   

C#

 
GeneralRe: OpenSSL.NET Tutorial? Pin
Kiotaya2-Mar-10 13:27
Kiotaya2-Mar-10 13:27 
QuestionPoor thumbnail quality when using listview Pin
Eagle3226-Feb-10 9:36
Eagle3226-Feb-10 9:36 
AnswerRe: Poor thumbnail quality when using listview Pin
Luc Pattyn26-Feb-10 10:13
sitebuilderLuc Pattyn26-Feb-10 10:13 
GeneralRe: Poor thumbnail quality when using listview Pin
Eagle3226-Feb-10 11:38
Eagle3226-Feb-10 11:38 
AnswerRe: Poor thumbnail quality when using listview [modified] Pin
Luc Pattyn26-Feb-10 12:20
sitebuilderLuc Pattyn26-Feb-10 12:20 
GeneralRe: Poor thumbnail quality when using listview Pin
Eagle3227-Feb-10 0:24
Eagle3227-Feb-10 0:24 
GeneralRe: Poor thumbnail quality when using listview Pin
Luc Pattyn27-Feb-10 0:37
sitebuilderLuc Pattyn27-Feb-10 0:37 
GeneralRe: Poor thumbnail quality when using listview Pin
Eagle3227-Feb-10 6:44
Eagle3227-Feb-10 6:44 
Hi,

I am testing the following code. Its just the images which are 640 x 480 appear to be cut off on the right hand side. What i mean is say you have a picture(640 x 480) of a Table but on the right side of the table there is something there, say a bowl of fruit, if i use the method below it cuts it off so you dont see the remaining contents of the image.

I did set the boolean parameter to true but i am not sure why the problem is occuring with those image sizes? I assumed that it would keep the aspect ratio.

public Bitmap ResizeImageKeepingAspectRatio(Image bm1, int w2, int h2, Brush backColor, bool centered) 
{
			int w1=bm1.Width;
			int h1=bm1.Height;
			Bitmap bm2=new Bitmap(w2, h2);
			Graphics g=Graphics.FromImage(bm2);
			g.FillRectangle(backColor, 0, 0, w2, h2);
			int x2=0;
			int y2=0;
			float scale=1;
			if (w1*h2 > w2*h1) {// w2 is the limiting factor
			   if (centered) y2=h2*w1/w2-h1;
			   scale=w2/(float)w1;
			} else {          // h2 is the limiting factor
			   if (centered) x2=w2*h1/h2-w1;
			   scale=h2/(float)h1;
			}
			g.ScaleTransform(scale, scale);
			g.TranslateTransform(x2/2, y2/2);
			g.DrawImage(bm1, 0, 0);
			g.Dispose();
			return bm2;
		}


Here is the code i am using in the button click
StaffImageList.ImageSize = new Size(120, 120);
this.StaffListView.View = View.LargeIcon;
StaffImageList.Images.Add(fPath, ResizeImageKeepingAspectRatio(img,StaffImageList.ImageSize.Width,StaffImageList.ImageSize.Height, brush, true));


Could you advise please?

Thanks
GeneralRe: Poor thumbnail quality when using listview Pin
Luc Pattyn27-Feb-10 7:40
sitebuilderLuc Pattyn27-Feb-10 7:40 
GeneralRe: Poor thumbnail quality when using listview Pin
Eagle3227-Feb-10 7:59
Eagle3227-Feb-10 7:59 
GeneralRe: Poor thumbnail quality when using listview Pin
Luc Pattyn27-Feb-10 8:14
sitebuilderLuc Pattyn27-Feb-10 8:14 
GeneralRe: Poor thumbnail quality when using listview Pin
Eagle325-Mar-10 10:08
Eagle325-Mar-10 10:08 
AnswerRe: Poor thumbnail quality when using listview Pin
Luc Pattyn26-Feb-10 12:53
sitebuilderLuc Pattyn26-Feb-10 12:53 
Questionhow to create a cookie with C# ??? Pin
andyxfun26-Feb-10 8:37
andyxfun26-Feb-10 8:37 
AnswerRe: how to create a cookie with C# ??? Pin
Saksida Bojan26-Feb-10 8:56
Saksida Bojan26-Feb-10 8:56 
Questionvoice chat in windows mobile 6 Pin
Rodinho26-Feb-10 7:53
Rodinho26-Feb-10 7:53 
AnswerRe: voice chat in windows mobile 6 Pin
Dr.Walt Fair, PE26-Feb-10 8:46
professionalDr.Walt Fair, PE26-Feb-10 8:46 
GeneralRe: voice chat in windows mobile 6 Pin
Wes Aday26-Feb-10 9:03
professionalWes Aday26-Feb-10 9:03 
AnswerRe: voice chat in windows mobile 6 Pin
rioshzhao23-Sep-10 20:02
rioshzhao23-Sep-10 20:02 
QuestionCreate and remove controls dynamically ?????? Pin
Pawan Kiran26-Feb-10 7:29
Pawan Kiran26-Feb-10 7:29 
AnswerRe: Create and remove controls dynamically ?????? Pin
PIEBALDconsult26-Feb-10 7:36
mvePIEBALDconsult26-Feb-10 7:36 
AnswerRe: Create and remove controls dynamically ?????? Pin
kevinnicol26-Feb-10 7:36
kevinnicol26-Feb-10 7:36 
AnswerRe: Create and remove controls dynamically ?????? Pin
dan!sh 26-Feb-10 7:53
professional dan!sh 26-Feb-10 7:53 
Questiontext to excell Pin
michaelgr126-Feb-10 7:20
michaelgr126-Feb-10 7:20 
AnswerRe: text to excell Pin
dan!sh 26-Feb-10 7:26
professional dan!sh 26-Feb-10 7:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.