Click here to Skip to main content
15,908,274 members
Home / Discussions / C#
   

C#

 
GeneralRe: Patch file (Create new file from previous file + changes) Pin
sodevrom27-Feb-10 14:41
sodevrom27-Feb-10 14:41 
GeneralRe: Patch file (Create new file from previous file + changes) Pin
Dave Kreskowiak27-Feb-10 18:53
mveDave Kreskowiak27-Feb-10 18:53 
Questionquestion about webviewer control Pin
tonyonlinux26-Feb-10 12:46
tonyonlinux26-Feb-10 12:46 
AnswerRe: question about webviewer control Pin
AspDotNetDev26-Feb-10 13:18
protectorAspDotNetDev26-Feb-10 13:18 
GeneralRe: question about webviewer control Pin
tonyonlinux26-Feb-10 18:21
tonyonlinux26-Feb-10 18:21 
QuestionOpenSSL.NET Tutorial? [modified] Pin
Kiotaya26-Feb-10 11:13
Kiotaya26-Feb-10 11:13 
AnswerRe: OpenSSL.NET Tutorial? Pin
carlecomm27-Feb-10 0:10
carlecomm27-Feb-10 0:10 
GeneralRe: OpenSSL.NET Tutorial? Pin
Kiotaya2-Mar-10 13:20
Kiotaya2-Mar-10 13:20 
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 
Untested (see also my next message):

// input:  Bitmap bm1, size w1*h1
// output: Bitmap bm2, size w2*h2
public Bitmap ResizeImageKeepingAspectRatio(Bitmap bm1, int w2, int h2, Brush backColor) {
    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
       y2=h2-h1*w2/w1);
       scale=w2/(float)w1;
    } else {          // h2 is the limiting factor
       x2=w2-w1*h2/h1);
       scale=h2/(float)h1;
    }
    g.ScaleTransform(scale, scale);
    g.TranslateTransform(x2/2, y2/2);
    g.DrawImage(bm1, 0, 0);
    g.Dispose();
    return bm2;
}


You need to test this; I suggest you give it a 100*100 and convert it to first a 40*50, and then a 50*40.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.

modified on Friday, February 26, 2010 6:54 PM

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 
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 

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.