larger Windows Icon images

  • Thread starter Thread starter Christ Kennedy
  • Start date Start date
C

Christ Kennedy

Guest
I'm writing a FileDialog-GUI and using icons

_bmp = new Bitmap(recArea.Width, recArea.Height);
using (Graphics g = Graphics.FromImage(_bmp))
{
g.FillRectangle(cParentRegion.brBackground, new RectangleF(0, 0, _bmp.Width, _bmp.Height));
Icon icoFile = classFileIcons.Search(cTI.fileInfo.Extension);
if (icoFile == null)
{
icoFile = System.Drawing.Icon.ExtractAssociatedIcon(cTI.fileInfo.FullName);//.ToBitmap();
if (icoFile != null)
classFileIcons.Insert(cTI.fileInfo.Extension, ref icoFile);
else
;
}
bmpFile = (Bitmap)icoFile.ToBitmap();
g.FillRectangle(cParentRegion.brBackground, new RectangleF(0, 0, recArea.Width, recArea.Height));
double dblAspectRatio = (double)bmpFile.Height / (double)bmpFile.Width;
if (dblAspectRatio > 1)
{ // height is limiting factor
Rectangle recSource = new Rectangle(0, 0, bmpFile.Width, bmpFile.Height);
Rectangle recDest = new Rectangle(0, 0, (int)((double)szIcon.Height / dblAspectRatio), szIcon.Height);
g.DrawImage(bmpFile, recDest, recSource, GraphicsUnit.Pixel);
g.DrawString(cTI.strName, cParentRegion.font, cParentRegion.brForeground, ptTextLocation);
}
else
{ // width is limiting factor
Rectangle recSource = new Rectangle(0, 0, bmpFile.Width, bmpFile.Height);
Rectangle recDest = new Rectangle(0, 0, szIcon.Width, (int)((double)szIcon.Width * dblAspectRatio));
g.DrawImage(bmpFile, recDest, recSource, GraphicsUnit.Pixel);
g.DrawString(cTI.strName, cParentRegion.font, cParentRegion.brForeground, ptTextLocation);
}
bmpFile = null;
g.DrawString(cTI.strName, cParentRegion.font, cParentRegion.brForeground, ptTextLocation);
}

as you can see in the image below, when the user selects 'Large Icons' the resultant images are blurry because the source image is so small.

1522623.png

Are there larger icon source images available?



my code is perfect until i don't find a bug

Continue reading...
 
Back
Top