- nettiergeneratorsample.zip
- database
- sample
- BusinessLogic
- Common
- Config
- DalFactory
- GUI
- WinGUI
- IDAL
- Model
- MsSqlDal
- OP_CACHE.ATR
- OP_CACHE.IDX
- Sample.sln
- Security
- TierModel
- Tools
- EnterpriseLibrary
- Microsoft.Practices.EnterpriseLibrary.Caching.dll
- Microsoft.Practices.EnterpriseLibrary.Caching.XML
- Microsoft.Practices.EnterpriseLibrary.Common.dll
- Microsoft.Practices.EnterpriseLibrary.Common.XML
- Microsoft.Practices.ObjectBuilder.dll
- Microsoft.Practices.ObjectBuilder.XML
- TierGenerator
- nettiergenerator.zip
- netTierGenerator
- BusinessLogic
- Common
- Common.csproj
- Data
- Exception
- OP_CACHE.ATR
- OP_CACHE.IDX
- Properties
- Util
- Config
- Console
- DalFactory
- IDal
- Model
- MsSqlDal
- netTierGenerator.sln
- OP_CACHE.ATR
- OP_CACHE.IDX
- TierGenerator
- TierModel
|
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
namespace Sample.Common.Util
{
public static class ImageUtil
{
public static byte[] ResizeImage(Stream stream, int height, int width)
{
return ImageUtil.ResizeImage(new Bitmap(stream), height, width);
}
public static byte[] ResizeImage(Image image, int height, int width)
{
Image.GetThumbnailImageAbort thumbnailCallback = new Image.GetThumbnailImageAbort(ImageUtil.ThumbnailCallback);
Image thumbnailBitmap = image.GetThumbnailImage(width, height, thumbnailCallback, IntPtr.Zero);
MemoryStream msThumbnail = new MemoryStream();
thumbnailBitmap.Save(msThumbnail, image.RawFormat);
byte[] bytesThumbnail = new byte[msThumbnail.Length];
msThumbnail.Seek(0, SeekOrigin.Begin);
msThumbnail.Read(bytesThumbnail, 0, bytesThumbnail.Length);
byte[] result = new byte[(int)msThumbnail.Length];
msThumbnail.Position = 0;
msThumbnail.Read(result, 0, (int)msThumbnail.Length);
return result;
}
#region Helper Methods
private static bool ThumbnailCallback()
{
return false;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.