473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

vb.net Load JPG in a Picture Box without Locking File

Hy Guys,
I have a problem loading JPG in a Picture Box.

I need to load a jpg files into a PB and then unlock the original JPG.
I'm using following code:

Dim picture1 As PictureBox
Dim OriginalImage As New Bitmap(FilePath) 'Load orginal
JPG
Dim iImage As New Bitmap(OriginalImage) 'Copy ii into a
tmp
OriginalImage.Dispose()
picture1.Image = iImage
iImage = Nothing
OriginalImage = Nothing
This code will work sometime yes and some time not.
I mean that sometime the file will unlock immediately, sometime it
takes to unlock 10/20 seconds and sometime never unlock.

Any help would be appreciated.

Many Thanks

Marco

Aug 30 '07 #1
2 7033
I need to load a jpg files into a PB and then unlock the original JPG.

Load it into a memory stream(i.e., Use the FileStream object).
Decode the image using the Bitmap constructor for a stream object.
Once loaded and decoded from the stream, there is no need for the system to
retain a file lock on the original file.

"Marcolino" <ma************@gmail.comwrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
Hy Guys,
I have a problem loading JPG in a Picture Box.

I need to load a jpg files into a PB and then unlock the original JPG.
I'm using following code:

Dim picture1 As PictureBox
Dim OriginalImage As New Bitmap(FilePath) 'Load orginal
JPG
Dim iImage As New Bitmap(OriginalImage) 'Copy ii into a
tmp
OriginalImage.Dispose()
picture1.Image = iImage
iImage = Nothing
OriginalImage = Nothing
This code will work sometime yes and some time not.
I mean that sometime the file will unlock immediately, sometime it
takes to unlock 10/20 seconds and sometime never unlock.

Any help would be appreciated.

Many Thanks

Marco

Aug 30 '07 #2
On 30 Ago, 16:05, Marcolino <marco.pozzu...@gmail.comwrote:
Hy Guys,
I have a problem loading JPG in a Picture Box.

I need to load a jpg files into a PB and then unlock the original JPG.
I'm using following code:

Dim picture1 As PictureBox
Dim OriginalImage As New Bitmap(FilePath) 'Load orginal
JPG
Dim iImage As New Bitmap(OriginalImage) 'Copy ii into a
tmp
OriginalImage.Dispose()

picture1.Image = iImage
iImage = Nothing
OriginalImage = Nothing

This code will work sometime yes and some time not.
I mean that sometime the file will unlock immediately, sometime it
takes to unlock 10/20 seconds and sometime never unlock.

Any help would be appreciated.

Many Thanks

Marco
Probably the easiest thing is just to draw the image on a new bitmap
created in memory
and, then, use this bitmap as image for the picture box.

Tommaso
http://groups.google.it/group/DataTime

Aug 31 '07 #3

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

Similar topics

2
by: Dariusz | last post by:
I have a problem with a call a Javascript "window.open()" function which is executed as part of a PHP file when a user clicks on an thumbnail image. The PHP is executed which passes some variables...
3
by: Trevor Fairchild | last post by:
I am making a program that categorizes pictures. The picture paths are stored in an Access Database, vb6 connects using adodc controls. This program works specifically with .jpg files. It will be...
6
by: Praveen Ramesh | last post by:
Hi, Is there anyway I can determine when exactly a module file I have (part of a bigger assembly) gets loaded into memory? The AssemblyLoad event tells me when exactly an assembly gets loaded,...
7
by: Eric.Jones | last post by:
I've encountered a strange error with loading delimited files from a Samba (SMB) network drive, has anyone else seen this before? (Platform: WinXP Pro, UDB PE 8015, level 02060106, SAMPLE db) ...
0
by: Scott Meddows | last post by:
I want to load a multipage TIFF image into memory as an Image object but I read that the FromFile method locks the file. Can I load this into a stream, close the physical file then manipulate the...
1
by: jz | last post by:
Hi All, I have an ActiveX control project, in the main form, I have an image control and load a JPG image from by setting Picture property of Image; I build it and everything is good, I...
4
by: John please don't spam me! | last post by:
VB.Net 2003 Hi, 2 questions: 1. I want to read a file in without locking it, as it is Log file. 2. I want to be able to read from the last point it wa read upto. The project is: Search...
2
elamberdor
by: elamberdor | last post by:
Hi All! Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map, ..well now I want to load in...
1
anfetienne
by: anfetienne | last post by:
i have this code below that i made....it loads vars from txt file splits it then puts it into an array....once in an array it the brings the pics in from the array to create thumbnails and a larger...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.