views:

41

answers:

3

hi,

I have create a bitmap. it's width 500px, and height 500px..

And i have an image. it's w : 300px, h:300px;

i want to set image to bitmap 500px, 500px without space or black background.

Could u help me pls.

Ty.

+2  A: 

See the documentation for Graphics.DrawImage. You can specify source and destination rectangles.

Example code:

        Image i = Image.FromFile(fileName); // This is 300x300
        Bitmap b = new Bitmap(500, 500);

        using(Graphics g = Graphics.FromImage(b))
        {
            g.DrawImage(i, 0, 0, 500, 500);
        }
bde
it is not working
yasink
any particular reason that you see for why it isn't working? an error? what happens when you run the code?
bde
A: 

SD.Bitmap bitmap = new SD.Bitmap(OriginalImage,newBigWidth,newBigHeight);

yasink
This is not an answer. Please delete and edit your original question.
Wonko the Sane
A: 

Hello,

You could try using the following:

public Image ImageZoom(Image image, Size newSize)
    {
        var bitmap = new Bitmap(image, newSize.Width, newSize.Height);
        using (var g = Graphics.FromImage(bitmap))
        {
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
        }

        return bitmap;
    }

And choose form one of the available InterpolationModes

Best Regards,

Emanuel Varga

Emanuel Varga