|
To back up what Richard says, what you are asking for is logically impossible: it's like saying "write me a summary of this book, but don't read it first". You can't write an accurate summary without knowing what happens in the story!
The same applies to images: you can't create a thumbnail without access to the original image.
So as Richard suggests: think about the problem you are trying to solve instead of the solution you have conceived - there may be a better way to complete your task. Or even a possible one!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
FileStream fs = new System.IO.FileStream(img_path, FileMode.Open, FileAccess.Read);
img = Image.FromStream(fs);
Image imgThumb = img.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero);
fs.Close();
fs.Dispose();
img.Dispose();
i use this for getting thumbnail, but it takes time if file is large,or i take tumbnail of multiple big size images....
that's why i ask its possible to get image thumbnail without using the image file.
is this possible with the use of "IExtractImage"
|
|
|
|
|
You're going to have the performance problem no matter what. Even using whatever interface that is, it's going to have to open the file and read the entire thing to generate the thumbnail.
|
|
|
|
|
As Dave has said, no - it's not possible.
However, there are two things you might consider to speed things up:
1) Cache your thumbnails. Create a new folder (if it doesn't exist) below the source image folder called "Thumbs", and when you need a thumbnail check that folder first for a file of the same name. If it exists, just read the thumbnail file. If it doesn't, generate the thumbnail and add it to the Thumbs folder. That doesn't speed everything up, but the second and successive times it will.
2) Do the above, but add a background thread that checks the images folder for "missing thumbs" and create them as needed. That again doesn't speed anything up, but it moves the generation into the background and "pre-prepares" thumbs that haven't been asked for yet.
Obviously, it'll take some work to ensure everything doesn't start colliding and your app crashes as a result, but it's that or insist that the images need to be added to your app before they are used (and creating the thumbnail then) - which may not be possible / convenient for your users / app.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Some file formats allow embedding a thumbnail in metadata. For example JPG allows it in the EXIF data section.
Not all image formats support this, and even if they do, not all images will have it. And even if it is present, the quality might not be sufficient.
I have not looked at it for years (decade+) so have no code nor libraries, but maybe googling "EXIF thumbnail c#" or similar will help.
|
|
|
|
|
Le@rner wrote: is there any option to get image file thumbnail ,but without open the image file.
Using those requirements and NOTHING else, then yes.
Create (or buy, acquire) say 100 or 1000 very small images.
Then for each file assign one of those to the file either sequentially or randomly. The number of files will determine if you produce repeats.
You could also just populate a small image with random data also. A variation of that is to use the name of the file and/or the current date/time as a seed for the random data.
|
|
|
|
|
i am create a PDF file using Microsoft Print to PDF,
PaperSize paperSize = new PaperSize("Custom", 400, 200);
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";
pd.PrinterSettings.PrintToFile = true;
pd.PrinterSettings.PrintFileName = PDF_File_name;
pd.DefaultPageSettings = Default_PrintProfile_PDF;
pd.PrinterSettings.DefaultPageSettings.PaperSize = paperSize;
pd.DefaultPageSettings.PaperSize = paperSize;
pd.PrintController = new StandardPrintController();
pd.PrintPage += PrintPage_As_PDF;
pd.Print();
but custom size not set, printable area is eqal to letter paper size.
please help me for this.
|
|
|
|
|
Yousef10 @ stackoverflow (SOS: "Microsoft Print PDF" PaperSize) says "don't worry" ... it's the printer's fault. And your code's the same as his; so first step -> try running your print PDF routine with a different printer?
|
|
|
|
|
Is there a way to set where to drop an event handler? When I double click on a button it drops mine at line 1500 for some reason. Then I have to cut and paste. It's doing it in a region of code and it expands that region, which is a little annoying. I'm hoping to drop at the top somewhere, possible?
|
|
|
|
|
Annoying, isn't it?
I've never found a solution to that either, and I've been using VS for 15 years ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
YES VERY VERY ANNOYING lol!! Kind of glad I'm not alone! Come on MicroSoft. Geez a whiz. It puts it in a random spot in the middle of nowhere. Where's the add event by line number?? That would make so much sense. Why MicroSoft Whyyyyy??? It would also be nice to apply a static do not expand my code unless I absolutely say so clause. And my last rant of the day is the 3 word line of code that can be simplified warning? Ok it's 3 words how much simpler can it be? I have a few more rants, but I'll table them for another day. Other than that it's a great product. And if I knew someone that was professional at this to tell me where and why's of doing things I would probably rant a lot less. But as it is all I have is Youtube and a lot of books. And nice forums like this one. So let's all be friends and give us our event handler by line number !
|
|
|
|
|
geomeo123 wrote: Where's the add event by line number?
Well ... no. Line number isn't helpful, and it's far too easy to add it in the wrong place and get code that doesn't compile - which might be quite difficult to spot! I'd rather have to move it to the right region of the file manually - which isn't hard to do - than have it appear in the middle of an XML comment, or a switch block for example.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Quote: and it's far too easy to add it in the wrong place and get code that doesn't compile
That would be pretty impossible. Since any time you click for the eventHandler MicroSoft prompts you exactly where your event code has landed so that you can start writing what you want to do when the event has occurred. I'm fairly sure choosing the line number rather than have that done for us would work.
|
|
|
|
|
You can manually add the handler name to your button in the properties window, and then add the actual handler code wherever you want.
|
|
|
|
|
Can you explain? You lost me on the word manually? Do you mean manually type it in to the event handler property text box then manually write it to whereever I want? Screenshots would be nice.
|
|
|
|
|
It seems that things have changed since I last did this, and even typing the event name into the event handler, VS automatically adds the handler skeleton at the end of the Form class.
|
|
|
|
|
Find a program with over 1500 lines of code. It doesn't add to the end of the code anymore. (which would be nice too).
|
|
|
|
|
Where would VS know where to definitively add the handler, other than at the end of the class definition in the first file of the class?
The code for a Form class could be spread across several files, so this makes identifying a target location harder. I organize my code in #region elements and have gotten (there - I said it ) used to moving the handler to an appropriate location.
/ravi
|
|
|
|
|
I don't understand your question?
|
|
|
|
|
I was suggesting there's no definitive way for VS to know where to place the new handler.
/ravi
|
|
|
|
|
Did you read the entire thread?
|
|
|
|
|
|
I have an application developed in Visual Studio 2022 that works with forms. In this application, there is a main form, from which other forms can be opened. In this main form, there is an item in the top menu (“selection”), whose name is M_Selecao, which must be activated or deactivated depending on which form was opened.
For example, when the “Expenses” form is opened, the menu must be activated (enabled).
When this secondary form is closed, the “selection” menu must be disabled. I can enable the menu, but I can’t disable it. I tried to make the main form’s menu “public” in the “TelaPrincipal.Designer.cs” file:
public System.Windows.Forms.ToolStripMenuItem M_Selecao;
This way I could disable the menu in the main form when closing the secondary form, but I get the message that "an object reference is required for the method or property 'TelaPrincipal.M_Selecao'. I also don't know how to do it from the main form. Can anyone help me? Thanks.
|
|
|
|
|
|
Ok, Richard. I'll try it. Thanks
|
|
|
|