FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

new Bitmap

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
zane.sims



Joined: 07 Aug 2007
Posts: 40

PostPosted: Tue Aug 07, 2007 5:10 pm    Post subject: new Bitmap Reply with quote

Sorry to ask such a simple question, but how do you create a new "Blank" bitmap. I don't see a constructor that appears to do the job. I want a Bitmap that I can use as a buffer for my PictureBox, but I want to start with a blank image instead of loading one from a file.

Thanks,
Zane
_________________
わたしがプログラマだよ!
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Aug 08, 2007 12:14 pm    Post subject: Re: new Bitmap Reply with quote

MemoryGraphics gives you a Graphics that is backed by a bitmap, which you can draw on and then copyTo something else.

I made a GraphicsBuffer addon that might give some insight.
Back to top
View user's profile Send private message
zane.sims



Joined: 07 Aug 2007
Posts: 40

PostPosted: Wed Aug 08, 2007 2:44 pm    Post subject: Reply with quote

Thanks for the help so far, but I still have some problems. It is possible that you have turned me in the right direction and that I just don't see it. I have more of a C# background and what my problem amounts to is that I want to implement a similar drawing scenario as the code demonstrates below (in psuedo C#).

Code:
private Bitmap bmp;
private PictureBox picBox;
private Graphics g;

public void init()
{
    bmp = new Bitmap(200,200);
    g = Graphics.FromImage(bmp);

    //skipping most of picBox setup for cause just an example
    picBox.Image = bmp;//set image that picBox will use
}

private void picBox_onSomeCoolEvent(Object sender, EventArgs ea)
{
    Pen p = new Pen(Color.Black);//Create a pen

    g.DrawLine(p, x1, y1, x2, y2);//draw to the image (bmp)

    picBox.Image = bmp;//update the picBox image to be painted
}


I am happy to see that most of DFL is very similar to C#.NET GUI coding, but that is also the very thing that gets me into trouble. Gets confusing at times. Shocked

Thanks for your time and efforts,
Zane
_________________
わたしがプログラマだよ!
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Sat Aug 11, 2007 5:18 pm    Post subject: Reply with quote

I just put up a snapshot that lets you get a Bitmap from a MemoryGraphics.

The way to use it is slightly different from the code you showed...

g = new MemoryGraphics(200, 200);
g.drawLine(p, x1, y1, x2, y2);
picBox.image = g.toBitmap();

Note that MemoryGraphics.toBitmap is a trial feature and could be removed.
Back to top
View user's profile Send private message
zane.sims



Joined: 07 Aug 2007
Posts: 40

PostPosted: Sat Aug 11, 2007 5:49 pm    Post subject: Reply with quote

Thanks a lot. In some ways, this works out better than the c# implementation.

Laters,
Zane
_________________
わたしがプログラマだよ!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group