|
Hi everybody,Can any one Help me how to create Thumbnails using C#.net. I am using VS2005.I have searched but
|
|
|
|
|
Look at the System.Drawing.Image.GetThumbnailImage method.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You can use GetThumbnailImage() to get a thumbnail. Most of the time this will give poor quality images. GetThumbnailImage() returns the embedded thumbnail from the image and re size to the specified size.
You can get good quality thumbnails by using Bitmap and Graphics classes. Try the following steps
1 - Create a Bitmap instance with the required width and height.
2 - Load the original image to a Graphics instance (Graphics.FromImage()).
3 - Use Graphics.DrawImage() to draw the image to bitmap.
bitmap instance will have the thumbnail image.
|
|
|
|
|
N a v a n e e t h wrote: 2 - Load the original image to a Graphics instance (Graphics.FromImage()).
That should rather be:
2 - Get a Graphics instance for drawing on the newly created Bitmap (Graphics.FromImage).
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: 2 - Get a Graphics instance for drawing on the newly created Bitmap (Graphics.FromImage).
Yeah. That is more clear.
|
|
|
|
|
Hi guys, msndn says that "The WebBrowser control cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code. " http://msdn.microsoft.com/en-us/library/8skskf63.aspx[^]">
Does it mean that I cannot instiante webbrowser control as shown below.
public partial class lralHTMLEditor : UserControl
{
public lralHTMLEditor()
{
WebBrowser webbrowser1 = new WebBrowser();
}
}
|
|
|
|
|
Partially trusted code does nothing have to do with partial classes, apart from the word "partial". So you can safely use a partial class here.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Read up on Code Access Security and that'll make much more sense. For example, try running your app from a local hard drive and it'll work. Try running it from a network source, i.e.: mapped network drive, and you'll get security exceptions. Network sources for managed code, by default, are not trusted sources, so they run inside a heavily restricted sandbox.
|
|
|
|
|
Hi everybody!
I'm doing my project and I'm getting this message with just one of the .txt files that I create before.
I made a .dll from a C++ project and it works perfectly. The objective of the DLL is to create three images and three .txt files, after it finishes I call the images, which is working perfectly, and then I call the .txt files. Two of them open perfect and they show me the respective data but when I do click on a button to call the third .txt to show me the data, on the Debug mode VS2005 tells me: "The process cannot access the file TXT because it is being used by another process"
I don't know if it is maybe because the DLL is still making the txt file or something like that, but I haven't found the solution to my issue.
Here is a part of my code that is working with the other two files but it isn't with the last one:
int columnas = 0;
string puntoycoma, array3 = "";
string[] lines = System.IO.File.ReadAllLines(VariablesGlobales.path1 + "results\\correspondencias3.txt");
puntoycoma = lines[0];
int filas = lines.Length;
The part that is in black is where I read the .txt file.
I hope you can help me, I'm getting desperated!!
Thanks a lot for your attention, if you need more information about my code, I'm gonna be looking my mail all the time in case i receive a response from you.
|
|
|
|
|
Did you forget to call Close() on the file stream in the
code that creates the file?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Well, I'm working with a another guy on my project, he is the one who knows how to work with C++. But while I contact him I can show you what he did:
First he creates the file and a pointer to the file or namefile:
Cmatrix correspondencias1;
correspondencias1.crea_matriz(width, height, 4);
FILE *streamp = fopen("results/correspondencias1.txt", "w");
Then he makes this to fill the file with the matrix columns and rows.
for (y= 0; y<H ; y++)
{
int *current = &m_disparity.Pixel(0, y, 0);
for (x = 0; x < W; x++)
{
correspondencias3.asignar_filas(x,y,current[x]);
if (x==W-1)
fprintf(streamt,"%d,%d %d,%d;\n",correspondencias3.matrix[x][y][0],correspondencias3.matrix[x][y][1],correspondencias3.matrix[x][y][2],correspondencias3.matrix[x][y][3]);
else
fprintf(streamt,"%d,%d %d,%d; ",correspondencias3.matrix[x][y][0],correspondencias3.matrix[x][y][1],correspondencias3.matrix[x][y][2],correspondencias3.matrix[x][y][3]);
}
}
fclose(streamt);
Well I saw the he used the fclose, I guess that this is what you meant, isn't it? streamt is a pointer, so it means that it is closing the file or not?
If you see that something is missing, please tell me and I tell him. I really appreciate your attention. Thanks a lot for your help.
|
|
|
|
|
That's what I meant, thanks.
I see
FILE *streamp = fopen(
and
fclose(streamt );
Is that just a typo?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oh, I'm sorry, I copied another part of the algorithm that creates one of the files that are working.
this is the parte where he declarates the streamt:
Cmatrix correspondencias3;
correspondencias3.crea_matriz(W,H,4);
FILE *streamt = fopen("results/correspondencias3.txt", "w");
and this is the part that it uses to create the .txt:
for (y= 0; y<H ; y++)
{
int *current = &m_disparity.Pixel(0, y, 0);
for (x = 0; x < W; x++)
{
correspondencias3.asignar_filas(x,y,current[x]);
if (x==W-1)
fprintf(streamt,"%d,%d %d,%d;\n",correspondencias3.matrix[x][y][0],correspondencias3.matrix[x][y][1],correspondencias3.matrix[x][y][2],correspondencias3.matrix[x][y][3]);
else
fprintf(streamt,"%d,%d %d,%d; ",correspondencias3.matrix[x][y][0],correspondencias3.matrix[x][y][1],correspondencias3.matrix[x][y][2],correspondencias3.matrix[x][y][3]);
}
}
fclose(streamt);
the problem is with correspondencias3.txt, correspondencias1.txt and correspondencias2.txt are working perfect.
if this is not the problem, what could it be?
thanks again for your help! I really really appreciate it!
if you need more info, just tell me.
|
|
|
|
|
Some process is holding the file open.
The only thing I can think of is step through the code -
especially from the point the file is opened (fopen()) to
where it gets closed (fclose()).
Make sure there's no execution paths that bypass the fclose().
Also check the return value of fclose().
Make sure there's no typos since you're working with 3 similarly named
sets of objects.
Good luck
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Well, I did it!
I didn't modify the file that was created by the C++ DLL. What I did was copying the file into another one.
In the C# I put this:
try
{
File.Copy(VariablesGlobales.path1 + "results\\correspondencias3.txt", VariablesGlobales.path1 + "results\\correspondencias4.txt");
}
catch
{
MessageBox.Show("No se pudo leer archivo de texto, favor haga click en Aceptar y espere un momento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
string[] lines = System.IO.File.ReadAllLines(VariablesGlobales.path1 + "results\\correspondencias4.txt");
I did a new one, a new .txt. That new one was the one that I read and copy to the new array!
Thanks a lot for your help again!
|
|
|
|
|
Thanks,but as per my requirement,without copying the file,i have to access the file.Any solution?please...
Regards,
Kiruthika
|
|
|
|
|
From my experience, the static methods of the "File" class are very slow compared to streams. Maybe 100 times slower. If you have concurrent access to a file it is best to make the reads and writes as short as possible.
I recommend replacing File.ReadAllLines with:
using (StreamReader sr = new StreamReader(...))
{
lines = sr.ReadToEnd();
}
Keyboard not found. Press F1 to continue.
|
|
|
|
|
How do I release the resources for an image so I can rename or delete it.
Bitmap pic = new Bitmap(infile);
pictureBox1.Image = pic;
// A button is clicked to rename or delete the picture
// I have tried
pic=null;
pictureBox1.Image=null;
File.Move(inpic, outpic);
//I get ************** Exception Text **************
//System.IO.IOException: The process cannot access the file because it is
//being used by another process.
I have seen this issue dealt with before but have not been able to find where.
|
|
|
|
|
The problem is that the picture was never Disposed. There are also bugs in the framework, I find the best thing is to create the bitmap, make a copy, work with the copy, and call Dispose on the original object. Setting to null doesn't do much, although it can increase the time before GC collects it, there's no immediate effect on the object.
Christian Graus
Driven to the arms of OSX by Vista.
"Iam doing the browsing center project in vb.net using c# coding" - this is why I don't answer questions much anymore. Oh, and Microsoft doesn't want me to.
|
|
|
|
|
electriac wrote: How do I release the resources for an image so I can rename or delete it.
Dispose it!
pic.Dispose();
pic=null;
GDI+ keeps the image stream open until you dispose the image.
It's buried way deep in the documentation - like a one sentence
blurb in an overview somewhere.
You can work with a clone as well, like Christian mentioned.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark that did the trick!
|
|
|
|
|
Hey there, it was my post about a month ago you're talking about Glad you found the solution , One more problem is in the pictureBox control "when loading it with a bitmap", more details are on msdn website..
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Do you have a URL for that I was not able to find it with a search.
|
|
|
|
|
|
Muammar
Thanks for the link.
I am doing a rewrite of my media player which displays images associated with the MP3 files. Since the program also deletes, renames, and exports groups of files I have had some difficulty do to the problem of unreleased resources. I believe that with the help of all you "Code Project" people I have everything working now.
Thanks to all
Electriac
|
|
|
|
|