Click here to Skip to main content
11,935,467 members (62,324 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked

Bitmap resize with .NET Compact Framework

, 15 Dec 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Bitmap resize with .NET Compact Framework

Hello. I develop C# with the .NET Compact Framework.

The support of images in C# is very poor. Not only that transparency is not supported, I also found no way to resize images with C# CF (3.5).

I searched for a long time to resize Bitmaps and I also found no simple way to make an DLL invoke for it.

My challenge was to resize an Bitmap object.

Finally, I found a solution which is working:

public static Bitmap resizeBitmap(Bitmap original, int newX, int newY) {
    Rectangle recSrc = new Rectangle(0, 0, original.Width, original.Height);
    Rectangle recDest = new Rectangle(0, 0, newX, newY);
    Bitmap target = new Bitmap(newX, newY);
    Graphics g = Graphics.FromImage(target);
    g.DrawImage(original, recDest, recSrc, GraphicsUnit.Pixel);
    return target;

Hopefully it helps somebody of you, so I'm posting it here.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Switzerland Switzerland
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralReason for my vote of 3 Nothing new... Pin
GPUToaster17-Nov-10 20:57
memberGPUToaster17-Nov-10 20:57 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151126.1 | Last Updated 15 Dec 2010
Article Copyright 2010 by BigManitu
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid