473,809 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use PictureBox.Imag e or DrawImage?

I do the following where sss is a string equal to a filename.

PictureBox.Imag e = = New Bitmap(sss)

It occurred to me that the file will be locked until the picturebox is
disposed at the program end.

Would it make more sense to use DrawImage.

I mean, is that what programmers typically do?

Thanks
Nov 20 '05 #1
2 4884
Hi,

If you open the bitmap with a filestream you won't lock the file.

Dim fs As New System.IO.FileS tream("C:\camer a.bmp",
IO.FileMode.Ope n)
Dim bm As New Bitmap(fs)

fs.Close()
PictureBox1.Ima ge = bm
Ken
---------------

"Just Me" <ne********@a-znet.com> wrote in message
news:Og******** ******@TK2MSFTN GP11.phx.gbl:
I do the following where sss is a string equal to a filename.

PictureBox.Imag e = = New Bitmap(sss)

It occurred to me that the file will be locked until the picturebox is
disposed at the program end.

Would it make more sense to use DrawImage.

I mean, is that what programmers typically do?

Thanks


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004
Nov 20 '05 #2
Perfect - thanks a lot

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:ee******** *****@TK2MSFTNG P12.phx.gbl...
Hi,

If you open the bitmap with a filestream you won't lock the file.

Dim fs As New System.IO.FileS tream("C:\camer a.bmp",
IO.FileMode.Ope n)
Dim bm As New Bitmap(fs)

fs.Close()
PictureBox1.Ima ge = bm
Ken
---------------

"Just Me" <ne********@a-znet.com> wrote in message
news:Og******** ******@TK2MSFTN GP11.phx.gbl:
I do the following where sss is a string equal to a filename.

PictureBox.Imag e = = New Bitmap(sss)

It occurred to me that the file will be locked until the picturebox is
disposed at the program end.

Would it make more sense to use DrawImage.

I mean, is that what programmers typically do?

Thanks


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004

Nov 20 '05 #3

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

Similar topics

2
3031
by: Sharon | last post by:
I encountered a strange behavior when doing ‘new Bitmap’: The following code works fine and the given bitmap file is shown on the PictureBox (the m_DrawArea) in the correct bitmap sizes: private Graphics m_gMapImg; private Bitmap m_backroundImage; private Bitmap MapImg; private PictureBox m_DrawArea;
2
2168
by: active | last post by:
Problem: The PictureBox display appears to have the image cut off. I.e., the image bottom does not display although the PictureBox has room for it. It occurred to me that what was displayed was the same size as the PictureBox was before it was resized. So I figured the bitmap was too small and tried to increase it's size as shown below. Two things: First it didn't fix the problem. Secondly, I'm not sure I've done it correctly and...
0
3886
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for your help, Here is the code.
1
2571
by: The Confessor | last post by:
I'm trying to develop a graphically-simple, gameplay-complex RPG, and I decided to create a graphical Proof of Concept just to confirm that graphics would be... well, simple. Predictably, they've proven otherwise. This is my PictureBoxMap_Paint() Sub, which a tiles a PictureBox with 19* 17 40*40-pixel images, two rows and two columns of which are painted beyond the current bounds of the picturebox to facilitate scrolling. The If/Else...
4
2011
by: TomA | last post by:
Hi All, I have a picturebox on a form containing the photo of a person. As you advance through the records, the photo updates. Rather than storing the images in an inefficient blob field in a table, I have the separate images stored in an image directory with primary key as the filename (3476.jpg). If the image exists, I display the image. All this works fine. I have a buttons that allow for the insertion and deletion of photos. ...
3
12367
by: prynhart | last post by:
I have a PictureBox Control which is 96*96 pixels. I want to display nine 32*32 pixel bitmaps in this control arranged in a 3X3 square. How can I do this ? All the examples I've seen load only one image in the PictureBox. The code: board.ClientSize = new Size(96, 96); board.Image = (Image)image1;
0
1316
by: kaushik123 | last post by:
ok, ive used a drawimage function inside a picturebox, Testbox Private Sub TestBox_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles TestBox.Paint ... .. e.Graphics.DrawImage(testimage, rect, 0, 0, wid, hgt, GraphicsUnit.Pixel, image_attr) End Sub
3
5381
by: kirk | last post by:
I have a form with a PictureBox control on it. The .Image property is set to a PNG file(which shows the picture of the US map) with some transparency in it. The .BackColor property is set to Transparent. This so far, works perfect. I now, would like to put another PNG image(an arrow showing positioning on the map) over the last PictureBox. The problem i'm having, the background for this second PictureBox only stays transparent when...
4
5604
by: gerardianlewis | last post by:
Any help appreciated. (VB.NET under XP and Vista, SP1 installed) My code, inherited from a VB6 version of an app that ran under W98, loads an image from a file into a PictureBox. The user may want to move or delete the file that is being shown. The corresponding event- driven code for "delete this picture" uses: My.Computer.FileSystem.DeleteFile(sPath)
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10633
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.