|
-
July 19th, 2005, 10:22 AM
#1
Why is it locked?
Hello,
I have created a static C++ DLL and exported a function on it. The function creates a .gif file. I then interface the DLL in my C# project and I call the C++ function through C++.
I view the .gif file that has been created in a pictureBox. When I clear the pictureBox and try to view the .gif, an NullPointerException is thrown!
When I try to delete the .gif file manulaly, it says that another process is using the .gif file.
I figured that MyC#Project.exe is the one locking my .gif 
Is there a way to be able to view .gif, clear them, and then view them again in the pictureBox?
Help Gurus!!
Ali
-
July 19th, 2005, 10:48 AM
#2
Re: Why is it locked?
Sounds to me like the file handle is being kept open - i.e. whichever code you're using to write the .gif isn't closing the file handle after it's finished.
Darwen.
-
July 19th, 2005, 03:06 PM
#3
Re: Why is it locked?
hi, how are you trying to create the gif file?
any information you can give me on creating gif files would be off great use?
-
July 19th, 2005, 04:53 PM
#4
Re: Why is it locked?
Hi djing1985,
I am using an open source library called GUIDO. There is a function to convert GUIDO music notation files (.gmn) to (.gif) files. You can use some functions in the library that are responsible of drawing the .gif file. I don't thik it is a "clean" way of getting what you want.
Anyways, here is the link:
http://sourceforge.net/projects/guidolib/
It is in C++ by the way.
Good Luck!
Ali
-
July 20th, 2005, 04:15 AM
#5
Re: Why is it locked?
ok cool thanks, i think your right though prob not what i want.
-
July 20th, 2005, 12:05 PM
#6
Re: Why is it locked?
Hello Darwen,
I finished checking all the fclose commands and everything is there! The .gif file is first drawn in the memory and then thrown into a file. Again, I am using an open source library, and here is how they draw the .gif - After it has been drawn in the memory- :
Code:
boolean GIF::WriteFile(const char* filename,GIF_FORMAT gf)
{
if((output_file=fopen(filename, WRITE_BINARY)) == NULL) return FALSE;
HeaderWriteFile();
PixelsWriteFile();
FinishWriteFile();
fclose(output_file);
if(gf==GIF89a)
{
rename(filename,"$tmpgif$.gif");
if(Gif87aToGif89a("$tmpgif$.gif",filename)) return FALSE;
}
return TRUE;
}
As you see, it is properly closed!
Other suggestions?
Ali
-
July 20th, 2005, 04:22 PM
#7
Re: Why is it locked?
I had a different similar problem.
My guess is that you are missing a Dispose() something in either your pictureBox code or in the display of the image.
-
July 20th, 2005, 06:22 PM
#8
Re: Why is it locked?
I agree. If you're using a FileStream to open a stream for C# to read the gif image you have to close it afterwards.
The nicest way of doing this is by the "using" keyword :
See here :
http://www.codeguru.com/Csharp/Cshar...cle.php/c8679/
Darwen.
-
July 21st, 2005, 01:20 PM
#9
Re: Why is it locked?
Ait! Works now!
Thanks guys!
Ali
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|