c# - drawing image to bigger bitmap -


basically want stretch smaller image (i.e. 300x300 bigger 1 i.e. 500x500) without space or black background.

i have bitmap (let's width 500px, , height 500px). how draw (smaller) image on bitmap takes whole bitmap?

i know how create bitmap (i.e. var bitmap = new bitmap(500, 500);) , image - can loaded file (i.e. var image = image.fromfile(...);) or obtained other source.

see documentation graphics.drawimage. can specify source , destination rectangles.

example code:

image = image.fromfile(filename); // 300x300 bitmap b = new bitmap(500, 500);  using(graphics g = graphics.fromimage(b)) {     g.drawimage(i, 0, 0, 500, 500); } 

to use code make sure add reference system.drawing assembly , add using system.drawing file.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -