c# - Display small image catalog in asp -


hi want put products catalog, how can crop picture small , save small , orginal?

try here:

c# thumbnail image getthumbnailimage

or here:

convert bitmap thumbnail

create thumbnail , reduce image size

create thumbnail image

update

for example can save image folder , can this:

var filename = "sourceimage.png";  using(var image = image.fromfile(filename)) {     using(var thumbnail = image.getthumbnailimage(20/*width*/, 40/*height*/, null, intptr.zero))     {         thumbnail.save("thumb.png");     } } 

update

to resize proportionally try this:

public bitmap proportionallyresizebitmap (bitmap src, int maxwidth, int maxheight) {  // original dimensions int w = src.width; int h = src.height;  // longest , shortest dimension int longestdimension = (w>h)?w: h; int shortestdimension = (w<h)?w: h;  // propotionality float factor = ((float)longestdimension) / shortestdimension;  // default width greater height double newwidth = maxwidth; double newheight = maxwidth/factor;  // if height greater width recalculate if ( w < h ) {     newwidth = maxheight / factor;     newheight = maxheight; }  // create new bitmap @ new dimensions bitmap result = new bitmap((int)newwidth, (int)newheight); using ( graphics g = graphics.fromimage((system.drawing.image)result) ) g.drawimage(src, 0, 0, (int)newwidth, (int)newheight);  return result; } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -