Draw image : Icon Image « 2D Graphics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » 2D Graphics » Icon ImageScreenshots 
Draw image
Draw image

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/
// Change the path(s) if needed. If you have VS.NET write:
// "..\\..\\Altamira5.bmp" or @"..\..\Altamira5.bmp"
// otherwise
// "Altamira5.bmp"
// and compile with:
// csc Altamira.cs

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Altamira
{
public class Altamira1 : Form
{
    Pen p;
    SolidBrush b, bT = new SolidBrush(Color.Black);
    string path = "Altamira5.bmp";  // change the path if needed
    Image im;
    Font f;

    public Altamira1()
    {
        InitializeComponent();
        MyIni();
    }

    private void InitializeComponent()
    {
        this.SuspendLayout();

        this.ClientSize = new System.Drawing.Size(290260);
        this.Text = "Altamira";

        this.ResumeLayout(false);
    }
    private void MyIni()
    {
        Color cP = Color.Gray;
        Color cB = Color.LightGray;

        p = new Pen(cP, 6);
        b = new SolidBrush(cB);
        im = Image.FromFile(path);
        f = new Font(new FontFamily("Times New Roman")10);
    }
    static void Main() 
    {
        Application.Run(new Altamira1());
    }
    protected override void OnPaint(PaintEventArgs pea)
    {
        Sketch();
        //SketchDBuf();
    }
    private void Sketch()
    {
        Graphics g = Graphics.FromHwnd(this.Handle);  // <=> g = CreateGraphics();

        g.FillRectangle(b, 44260220);  // passe-partout
        g.DrawRectangle(p, 44260220);  // frame
        g.DrawImage(im, 3335200145 );  // image
        g.DrawString("ALTAMIRA", f, bT, 180190);  // text

        g.Dispose();
    }
    private void SketchDBuf()
    {
        int hh = 3, w = 260, h = 220;   

        Graphics g;
        Bitmap bm = new Bitmap(w + 2*hh, h + 2*hh);
        g = Graphics.FromImage(bm);  // buffer graphics

        g.FillRectangle(b, hh , hh, w, h);  // passe-partout
        g.DrawRectangle(new Pen(Color.Gray,  2*hh), hh, hh, w, h);  // frame
        g.DrawImage(im, hh + 30, hh + 32200145);  // image
        g.DrawString("ALTAMIRA", f, bT, 180190);  // text

        g = Graphics.FromHwnd(this.Handle);  // real graphics
        g.DrawImage(bm, 11);

        g.Dispose();
    }
}
}


           
       
P01_Altamira.zip( 109 k)
Related examples in the same category
1.Image Paint Simple DemoImage Paint Simple Demo
2.Image Warper AppImage Warper App
3.Image Icon FormImage Icon Form
4.Icon Image DrawIcon Image Draw
5.Image ClassImage Class
6.MetaFile and DrawMetaFile and Draw
7.Picture ControlsPicture Controls
8.Control PaletteControl Palette
9.Cube ImageCube Image
10.Image Zoom 1Image Zoom 1
11.Image FlipImage Flip
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.