473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ 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(Original Image) 'Copy ii into a
tmp
OriginalImage.D ispose()
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 7051
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.goog legroups.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(Original Image) 'Copy ii into a
tmp
OriginalImage.D ispose()
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(Original Image) 'Copy ii into a
tmp
OriginalImage.D ispose()

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
3407
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 to Javascript to execute the new window opening. But as it does this, the main window is loaded which is blank (the browser URL bar shows the URL of the URL passed to the PHP / Javascript script). I would like to keep the gallery page visible...
3
13883
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 used by people categorizing thousands of images. The problem I have is that both the picture control, and the image control seem unable to open certain jpg images for an unknown reason. The error message simply states "Invalid Picture". I can...
6
2329
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, but not a module. Basically, I want to confirm that a module will NOT get loaded into memory UNTIL a type defined in that module is referenced. That's what I have read,
7
19632
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) db2 load from M:\org1.del of del replace into org SQL3109N The utility is beginning to load data from file "M:\org1.del". SQL2036N The path for the file or device "M:\org1.del" is not valid. db2diag.log:
0
322
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 image there? Thanks Scott
1
4694
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 checked in my file to Subversion server; and I checked out from another machine. when I tried to open my project, I got an errors: like Microsoft Visual basic, Errors during load, Refer to
4
9562
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 through ftp log files for certain files download to our ftp site. This will be on a schedule so I would like to pass to my database the point (in bytes) where I have read upto. Then next time I check it I want to only
2
3745
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 icons(images) instead of text. (yes i'm being difficult) and i'd like the text to load into a static placeholder symbol instead. Problem is, I can get images to load in a separate file, text to load in a separate file, and text to appear in a static...
1
3655
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 image. my problem is i have captions to go with it and when i try to load the captions nothing happens or can be seen to be happening. i dont know where i am going wrong as i have no output or compiled errors var locVar = new Array();...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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
10538
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
10305
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...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
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
9115
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
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4270
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

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.