public static CurrentDesktopDimensions GetDesktopDimensions() { const int SM_CXSCREEN = 0; const int SM_CYSCREEN = 1; CurrentDesktopDimensions oCDD = new CurrentDesktopDimensions(); oCDD.DesktopHeight = GetSystemMetrics(SM_CYSCREEN); oCDD.DesktopWidth = GetSystemMetrics(SM_CXSCREEN); return(oCDD); }
public void SaveImageToFile(string sImageText, Color backgroundColor , Color foregroundColor, string sOutputFile, CurrentDesktopDimensions oCDD) { // Create a background image of size and color basic bkg Bitmap objBmpImage = new Bitmap(oCDD.DesktopWidth, oCDD.DesktopHeight); // Create a graphics object to measure the text's width and height. Graphics objGraphics = Graphics.FromImage(objBmpImage); objGraphics = Graphics.FromImage(objBmpImage); // Set Background color objGraphics.Clear(backgroundColor); objGraphics.Flush(); // Construct a bitmap from the button image resource. Bitmap bmp1 = CreateBitmapImage(sImageText, foregroundColor); //bmp1.Save("c:\\_Dev\\testImage.gif", System.Drawing.Imaging.ImageFormat.Gif); //string mainBkg = @"C:\Documents and Settings\Administrator\Desktop\fs_logo_for_wallpaper.png"; System.Drawing.Image original = objBmpImage; Graphics gra = Graphics.FromImage(original); Bitmap logo = new Bitmap(bmp1); gra.DrawImage(logo, new Point(5, 5)); // Save the image as a GIF. //bmp1.Save("c:\\_Dev\\testImage.gif", System.Drawing.Imaging.ImageFormat.Gif); original.Save(sOutputFile, System.Drawing.Imaging.ImageFormat.Bmp); // Dispose of the image file. bmp1.Dispose(); }