public byte[] ArtworkImage(string filePath)
{
byte[] bytes = null;
string strFileName;
if (File.Exists(filePath))
{
strFileName = filePath;
}
else
{
strFileName = AppDomain.CurrentDomain.BaseDirectory + "NoImage.jpg";
}
try
{
using (MemoryStream mem = new MemoryStream())
{
using (Bitmap bmp = (Bitmap)Bitmap.FromFile(strFileName))
{
using (Bitmap bmpTemp = new Bitmap(150, 150, System.Drawing.Imaging.PixelFormat.Format24bppRgb))
{
Graphics g = Graphics.FromImage(bmpTemp);
g.DrawImage(bmp, 0, 0, 149, 149);
bmpTemp.Save(mem, System.Drawing.Imaging.ImageFormat.Jpeg);
bytes = mem.ToArray();
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
return bytes;
}