saimatkong
asked on
How to create thumbnail
How to create thumbnail ?
and i need to create the thumbnail for a particular filename for every folder under a particular folder.
thanks
and i need to create the thumbnail for a particular filename for every folder under a particular folder.
thanks
ASKER
hmm that's asp.net what i mean is C# win app.
and can it be loading all the date from different xml in diff sub folder under one folder
and load all the title into a list and when a list is being clicked, the image and the details is being loaded.
thanks again.
and can it be loading all the date from different xml in diff sub folder under one folder
and load all the title into a list and when a list is being clicked, the image and the details is being loaded.
thanks again.
saimatkong,
Don't worry, the code is not asp.net specific, you can transfer it to windows and get it to work in c#. The code I have shown above just mapped out the psuedo-code/logic, you will need to do the specifics for your application. It shows three things:
1) A main function that starts the process of recursively going through the subdirectories
2) A recursive function that will go into each directory within a directory. If there are no directories, or once it returns from the subdirectories, then you can process the files.
3) A CreateThumbnail function that uses the filename along with the System.Drawing.Bitmap objects to generate the thumbnail.
You can use the System.IO objects to fill your list. Then, when you click a file in that list you can use the System.Drawing.Bitmap object to get or create a thumbnail. To load all the files in all sub folders into a list you will need a recursive function, much like I've shown.
Andy
Don't worry, the code is not asp.net specific, you can transfer it to windows and get it to work in c#. The code I have shown above just mapped out the psuedo-code/logic, you will need to do the specifics for your application. It shows three things:
1) A main function that starts the process of recursively going through the subdirectories
2) A recursive function that will go into each directory within a directory. If there are no directories, or once it returns from the subdirectories, then you can process the files.
3) A CreateThumbnail function that uses the filename along with the System.Drawing.Bitmap objects to generate the thumbnail.
You can use the System.IO objects to fill your list. Then, when you click a file in that list you can use the System.Drawing.Bitmap object to get or create a thumbnail. To load all the files in all sub folders into a list you will need a recursive function, much like I've shown.
Andy
ASKER
thanks for ur help.
anyway it's not really the stuff that i'm looking for,
but really appriciate ur effort.
anyway it's not really the stuff that i'm looking for,
but really appriciate ur effort.
What kind of thumbnails are you looking for? Are you looking for the same type of thumbnails that Windows Explorer displays?
Bob
Bob
ASKER
ya something like tat.
thanks
thanks
saimatkong,
No problem. I'm not sure I fully understand your question if this isn't what you are looking for. As far as I know, there is no other way to generate thumbnails other than using the GDI+ objects in System.Drawing, either using the GetThumbnailImage or scaling an image yourself. I also don't know of any other way of loading a folder/file list into a list without using a recursive function with the System.IO objects. I'll watch with interest to see if anyone has a different solution.
Andy
No problem. I'm not sure I fully understand your question if this isn't what you are looking for. As far as I know, there is no other way to generate thumbnails other than using the GDI+ objects in System.Drawing, either using the GetThumbnailImage or scaling an image yourself. I also don't know of any other way of loading a folder/file list into a list without using a recursive function with the System.IO objects. I'll watch with interest to see if anyone has a different solution.
Andy
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Here is an example form (2003):
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
/// <summary>
/// Summary description for formShellThumbnail.
/// </summary>
public class formShellThumbnail : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Cont ainer components = null;
public formShellThumbnail()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new formShellThumbnail());
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.Pictu reBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(44, 28);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(112, 88);
this.pictureBox1.SizeMode = System.Windows.Forms.Pictu reBoxSizeM ode.AutoSi ze;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// formShellThumbnail
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(208, 162);
this.Controls.Add(this.pic tureBox1);
this.Name = "formShellThumbnail";
this.Text = "Shell Thumbnails";
this.Load += new System.EventHandler(this.f ormShellTh umbnail_Lo ad);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Pictu reBox pictureBox1;
private ShellThumbnail _shell = new ShellThumbnail();
private void formShellThumbnail_Load(ob ject sender, System.EventArgs e)
{
this.pictureBox1.Image = _shell.GetThumbnail(@"C:\W INDOWS\Web \Wallpaper \Autumn.jp g");
}
}
Bob
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
/// <summary>
/// Summary description for formShellThumbnail.
/// </summary>
public class formShellThumbnail : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Cont
public formShellThumbnail()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new formShellThumbnail());
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.Pictu
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(44, 28);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(112, 88);
this.pictureBox1.SizeMode = System.Windows.Forms.Pictu
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// formShellThumbnail
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(208, 162);
this.Controls.Add(this.pic
this.Name = "formShellThumbnail";
this.Text = "Shell Thumbnails";
this.Load += new System.EventHandler(this.f
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Pictu
private ShellThumbnail _shell = new ShellThumbnail();
private void formShellThumbnail_Load(ob
{
this.pictureBox1.Image = _shell.GetThumbnail(@"C:\W
}
}
Bob
ASKER
thansk anyway =)
ASKER
wow so long the code.
how to execute or call it btw ?
thanks
how to execute or call it btw ?
thanks
This code doesnt seem to work for PDF files. Any ideas why?
I am using ShellThumbnail in windows7 and it is returning folder thumbnail with black background, any help ???
Roughly, it would go something like:
<psuedo>
Main()
{
-Get parentDirectory as DirectoryInfo
RecurseDirectories(parentD
}
RecurseDirectories(Directo
{
-for each directory in parentDirectory.GetDirecto
-RecurseDirectories(direct
-for each file in parentDirectory.GetFiles("
}
CreateThumbnail(string FileInfoFullName)
{
using (System.Drawing.Bitmap bmp = new Bitmap(FileInfoFullName))
{
-manipulate bmp using bmp.GetThumbnailImage() and save it to a file
}
}
</psuedo>
Good references for doing the thumbnail creation:
http://www.codeproject.com/aspnet/thumbtools.asp
Andy