Click here to Skip to main content
15,914,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have created a small-yellow rectangle using following code. But it is always displaying at the top. Other control(eg.textbox/button) on same page is not visible.
C#
//=======================================
protected void Page_Load(object sender, EventArgs e)
    {
        Bitmap objBMP = new Bitmap(60, 20);
        Graphics objGraphics = Graphics.FromImage(objBMP);

        objGraphics.Clear(Color.Yellow);
        objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;

        Response.ContentType = "image/GIF";
        objBMP.Save(Response.OutputStream, ImageFormat.Gif);        
        objGraphics.Dispose();
        objBMP.Dispose();

    }
//======================================


What shall I do to display this in a td-tag within a table-tag and view all other content of the same page?
Posted
Updated 24-Nov-11 7:03am
v3

1 solution

use these code:
For Postioning:
The following code example shows how to construct a Bitmap from the file Climber.jpg and displays the bitmap. The destination point for the upper-left corner of the image, (10, 10), is specified in the second and third parameters.
C#:
Bitmap myBitmap = new Bitmap("Climber.jpg");
myGraphics.DrawImage(myBitmap, 10, 10);

Then cloning also in these part u can also use these also:
The Bitmap class provides a Clone method that you can use to make a copy of an existing Bitmap. The Clone method has a source rectangle parameter that you can use to specify the portion of the original bitmap that you want to copy. The following code example shows how to create a Bitmap by cloning the top half of an existing Bitmap. Then both images are drawn.
C#


Bitmap originalBitmap = new Bitmap("Spiral.png");
Rectangle sourceRectangle = new Rectangle(0, 0, originalBitmap.Width,
originalBitmap.Height / 2);

Bitmap secondBitmap = originalBitmap.Clone(sourceRectangle,
PixelFormat.DontCare);

myGraphics.DrawImage(originalBitmap, 10, 10);
myGraphics.DrawImage(secondBitmap, 150, 10);
 
Share this answer
 
Comments
SHAJANCHERIAN 26-Nov-11 3:20am    
Can I bind the bitmap to any imageControl on the same page without saving this bitmap to anywhere. Because other control on the same page is not visible now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900