473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Making Bitmaps and Graphics objects - two ways

Stumbling through I find both of the following appear to work the same.

I'm guessing there is a difference that I'm just not aware of.

Can someone enlighten me?

Thanks

'This works (4 lines)

Dim TmpBitmapGraphics As Graphics = PictureBoxPic.CreateGraphics

Dim TmpBitmap As New Drawing.Bitmap(PictureBoxPic.ClientSize.Width,
PictureBoxPic.ClientSize.Height, TmpBitmapGraphics)

TmpBitmapGraphics.Dispose() 'Did the above to preserver the PixelFormat

TmpBitmapGraphics = Graphics.FromImage(TmpBitmap)

'This also works (2 lines)

Dim TmpBitmap As New Drawing.Bitmap(PictureBoxPic.ClientSize.Width,
PictureBoxPic.ClientSize.Height)

Dim TmpBitmapGraphics As Graphics = Graphics.FromImage(TmpBitmap)
Feb 4 '06 #1
2 1252
**Developer** wrote:
Stumbling through I find both of the following appear to work the same.

I'm guessing there is a difference that I'm just not aware of.

Can someone enlighten me?

Thanks

'This works (4 lines)

Dim TmpBitmapGraphics As Graphics = PictureBoxPic.CreateGraphics

Dim TmpBitmap As New Drawing.Bitmap(PictureBoxPic.ClientSize.Width,
PictureBoxPic.ClientSize.Height, TmpBitmapGraphics)

TmpBitmapGraphics.Dispose() 'Did the above to preserver the PixelFormat

TmpBitmapGraphics = Graphics.FromImage(TmpBitmap)

'This also works (2 lines)

Dim TmpBitmap As New Drawing.Bitmap(PictureBoxPic.ClientSize.Width,
PictureBoxPic.ClientSize.Height)

Dim TmpBitmapGraphics As Graphics = Graphics.FromImage(TmpBitmap)


'Set it to the picture boxes graphics object
1. Dim TmpBitmapGraphics As Graphics = PictureBoxPic.CreateGraphics

2. Dim TmpBitmap As New Drawing.Bitmap(PictureBoxPic.ClientSize.Width,
PictureBoxPic.ClientSize.Height, TmpBitmapGraphics)

'Kill this object (this has the same effect as if you never did line 1
3. TmpBitmapGraphics.Dispose() 'Did the above to preserver the PixelFormat

' Set the object to something totally new.
4. TmpBitmapGraphics = Graphics.FromImage(TmpBitmap)

So it seems like this way of doing it is pretty pointless, since you
create the object and then just kill it right after.
Feb 4 '06 #2
..

'Set it to the picture boxes graphics object
1. Dim TmpBitmapGraphics As Graphics = PictureBoxPic.CreateGraphics

2. Dim TmpBitmap As New Drawing.Bitmap(PictureBoxPic.ClientSize.Width,
PictureBoxPic.ClientSize.Height, TmpBitmapGraphics)

'Kill this object (this has the same effect as if you never did line 1
Except Line 2 used it. Not sure about the effect though. Can an image in a
picturebox have different DPI? Or does it match the screen?

3. TmpBitmapGraphics.Dispose() 'Did the above to preserver the PixelFormat

' Set the object to something totally new.
4. TmpBitmapGraphics = Graphics.FromImage(TmpBitmap)

So it seems like this way of doing it is pretty pointless, since you
create the object and then just kill it right after.

Feb 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sandman | last post by:
Is this a one-time deal? Or something you want to do programmatically? If it's a one-time thing (e.g. to create a bitmap that you can then use in your program), just press Print-Screen, then load...
2
by: Phil | last post by:
is there anyway to connect to bitmaps together? basically, I have a program that generates a graph as it runs, and I can capture an image of the graph, but is there a way to take two captures, and...
3
by: James Dean | last post by:
I have 2 1bppindexed bitmaps and i want to combine both together. I converted both to 24bpp then tried to combine them but it didnt work. If possible i want to be able to draw one bitmap directly...
1
by: Kevin A. | last post by:
Hi all, I'm trying to make a little game in VB.NET that uses sprites (bitmaps) with a fixed size, currently 32x32 pixels. Now I was thinking: when I want to include objects in my game...
1
by: John | last post by:
I have 76 bitmaps (640 x 480) and need to combine them together to form a big one (about 3840 x 2880). Those 76 bitmaps overlap each other with a small portion. Is there any way to do it? Thanks.
2
by: Mike | last post by:
Hello everybody. I am drawing a country map that consists of 149 municipality bitmaps, each around 25 Kb. I draw it onto the in-memory bitmap, then draw it on the picture box. I use C++, but...
3
by: pradnyapatil29 | last post by:
I am trying to draw a chart similar to GANTT chart in asp.net. Right now, I am drawing the rectangles on bitmap...but I dont want to use bitmap . Coz loading bitmap takes time...Is there...
5
by: Ray Tomes | last post by:
Hi Folks I am an old codger who has much experience with computers in the distant past before all this object oriented stuff. Also I have loads of software in such languages as FORTRAN and...
1
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I need to combine several bitmaps together to form a single bitmap. Can anyone show me some similar sample code? Thanks. AJ
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.