熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp.net如何獲取圖片的分辨率

2022-06-13   來源: .NET編程 

  public void formatImage()

  {

  //格式化後的圖片大小

  int _WIDTH = ;

  int _HEIGHT = ;

  SystemDrawingImageGetThumbnailImageAbort myCallback = new SystemDrawingImageGetThumbnailImageAbort(ThumbnailCallback);

  SystemDrawingImage img = SystemDrawingImageFromFile(@d:\png);

  //制作縮略圖

  int width = imgWidth;

  int height = imgHeight;

  double divide = (double)height / (double)width;

  if (width > _WIDTH || height > _HEIGHT)

  {

  if (width > _WIDTH)

  {

  height = ConvertToInt(MathFloor(_WIDTH * divide));

  width = _WIDTH;

  }

  if (height > _HEIGHT)

  {

  width = ConvertToInt(MathFloor(_HEIGHT / divide));

  height = _HEIGHT;

  }

  SystemDrawingImage timg = imgGetThumbnailImage(width height myCallback SystemIntPtrZero);

  timgSave(@d:\jpg SystemDrawingImagingImageFormatJpeg);

  //下面的是保存到流中

  //MemoryStream ms = new MemoryStream();

  //timgSave(ms SystemDrawingImagingImageFormatJpeg);

  //msClose();

  }

  }

  public bool ThumbnailCallback()

  {

  return false;

  }


From:http://tw.wingwit.com/Article/program/net/201311/13712.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.