Csharp .Net doubt [modified]
-
hello every1, M new to this site so dont know how to post a query here if m wrong do correct me.M making a project in Csharp.Net on batch image processing.I can display multiple images n select it in check box but instead of checkboxes i want the thumbnail of the images to be displayed in the box.Can somebody please help.Thanks in advance......Here is the code that i coded in MS Visual Csharp 2008 express edition
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{Dictionary<string, string> ImageList = new Dictionary<string, string>(); public Form1() { InitializeComponent(); SetStyle(ControlStyles.ResizeRedraw, true); } private void button3\_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { DirectoryInfo FileDirectory = new DirectoryInfo(folderBrowserDialog1.SelectedPath); //FileInfo\[\] FilesFromDirectory = FileDirectory.GetFiles(); FileInfo\[\] FileJpg = FileDirectory.GetFiles("\*.jpg"); FileInfo\[\] FileGif = FileDirectory.GetFiles("\*.gif"); FileInfo\[\] FileBmp = FileDirectory.GetFiles("\*.bmp"); FileInfo\[\] FileTif = FileDirectory.GetFiles("\*.tif"); FileInfo\[\] FilePng = FileDirectory.GetFiles("\*.png"); foreach (FileInfo File in FileJpg) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileTif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo
Please edit your post and surround the code in the '
' tags, this will format it so it will appear to others just as you normally see it in Visual Studio. You can put the tags around the text yourself or highlight the text and then click the 'code block' option above the edit window. Also, what control are you using for displaying the images?
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
-
Please edit your post and surround the code in the '
' tags, this will format it so it will appear to others just as you normally see it in Visual Studio. You can put the tags around the text yourself or highlight the text and then click the 'code block' option above the edit window. Also, what control are you using for displaying the images?
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
i didnt get u @Ben what control means?????
-
Please edit your post and surround the code in the '
' tags, this will format it so it will appear to others just as you normally see it in Visual Studio. You can put the tags around the text yourself or highlight the text and then click the 'code block' option above the edit window. Also, what control are you using for displaying the images?
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
I believe you mean <pre>code here<pre/> tags. :D
-
hello every1, M new to this site so dont know how to post a query here if m wrong do correct me.M making a project in Csharp.Net on batch image processing.I can display multiple images n select it in check box but instead of checkboxes i want the thumbnail of the images to be displayed in the box.Can somebody please help.Thanks in advance......Here is the code that i coded in MS Visual Csharp 2008 express edition
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{Dictionary<string, string> ImageList = new Dictionary<string, string>(); public Form1() { InitializeComponent(); SetStyle(ControlStyles.ResizeRedraw, true); } private void button3\_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { DirectoryInfo FileDirectory = new DirectoryInfo(folderBrowserDialog1.SelectedPath); //FileInfo\[\] FilesFromDirectory = FileDirectory.GetFiles(); FileInfo\[\] FileJpg = FileDirectory.GetFiles("\*.jpg"); FileInfo\[\] FileGif = FileDirectory.GetFiles("\*.gif"); FileInfo\[\] FileBmp = FileDirectory.GetFiles("\*.bmp"); FileInfo\[\] FileTif = FileDirectory.GetFiles("\*.tif"); FileInfo\[\] FilePng = FileDirectory.GetFiles("\*.png"); foreach (FileInfo File in FileJpg) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileTif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo
I think you should restate your question as it's not terribly clear. You want to provide a way to select multiple images for batch processing, and you want to display thumbnails, but it all stops there for me. What are you having difficulty with? Drawing images to the screen? If so, have a look at the Graphics class.
-
i didnt get u @Ben what control means?????
Use <pre> tags to surround code blocks.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
I think you should restate your question as it's not terribly clear. You want to provide a way to select multiple images for batch processing, and you want to display thumbnails, but it all stops there for me. What are you having difficulty with? Drawing images to the screen? If so, have a look at the Graphics class.
till now i have put a checkbox and i can select multiple images through it n it is displayed in the preview box but instead of seeing just the name of the images in the checklist box i want the thumbnails of the images to be displayed along with the check button
-
I think you should restate your question as it's not terribly clear. You want to provide a way to select multiple images for batch processing, and you want to display thumbnails, but it all stops there for me. What are you having difficulty with? Drawing images to the screen? If so, have a look at the Graphics class.
[Message Deleted]
-
[Message Deleted]
If i click on add photos a new window pops to select a particular folder in whcih images are present.But i cannot select the particular image i have to select the whole folder and the names of these images are then displayed in the checklist box.I want the thumbnails of these images to be displayed in this box.When i will select a particular image it will be displayed in the preview box,There is also a problem here i cannot c the whole image but only a part of it.......I hope this will help u to clear my doubt.
-
till now i have put a checkbox and i can select multiple images through it n it is displayed in the preview box but instead of seeing just the name of the images in the checklist box i want the thumbnails of the images to be displayed along with the check button
It seems that you want to use a CheckedListBox and display thumbs instead of filenames. To do so I believe you must use the OwnerDraw method. Try googling it though - surely many have done the same or something similar before you.
-
hello every1, M new to this site so dont know how to post a query here if m wrong do correct me.M making a project in Csharp.Net on batch image processing.I can display multiple images n select it in check box but instead of checkboxes i want the thumbnail of the images to be displayed in the box.Can somebody please help.Thanks in advance......Here is the code that i coded in MS Visual Csharp 2008 express edition
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{Dictionary<string, string> ImageList = new Dictionary<string, string>(); public Form1() { InitializeComponent(); SetStyle(ControlStyles.ResizeRedraw, true); } private void button3\_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { DirectoryInfo FileDirectory = new DirectoryInfo(folderBrowserDialog1.SelectedPath); //FileInfo\[\] FilesFromDirectory = FileDirectory.GetFiles(); FileInfo\[\] FileJpg = FileDirectory.GetFiles("\*.jpg"); FileInfo\[\] FileGif = FileDirectory.GetFiles("\*.gif"); FileInfo\[\] FileBmp = FileDirectory.GetFiles("\*.bmp"); FileInfo\[\] FileTif = FileDirectory.GetFiles("\*.tif"); FileInfo\[\] FilePng = FileDirectory.GetFiles("\*.png"); foreach (FileInfo File in FileJpg) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileTif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo
Hi, one way to get what you want is this: 1. define a little MyImage class, containing a file name, a bitmap, a selected flag. 2. use a regular ListBox; it can show a collection of items of any type you choose (not just strings), so use it to hold instances of MyImage. 3. provide your own DrawItem handler to paint the MyImage any way you like (use Graphics.DrawString to show the file name, and DrawImage to draw a thumbnail) 4. add click and doubleclick handlers as you see fit. As an example, this little article[^] uses an owerdrawn ListBox in order to get colored text lines. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Happy New Year to all.
We hope 2010 soon brings us automatic PRE tags!
Until then, please insert them manually.
-
hello every1, M new to this site so dont know how to post a query here if m wrong do correct me.M making a project in Csharp.Net on batch image processing.I can display multiple images n select it in check box but instead of checkboxes i want the thumbnail of the images to be displayed in the box.Can somebody please help.Thanks in advance......Here is the code that i coded in MS Visual Csharp 2008 express edition
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{Dictionary<string, string> ImageList = new Dictionary<string, string>(); public Form1() { InitializeComponent(); SetStyle(ControlStyles.ResizeRedraw, true); } private void button3\_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { DirectoryInfo FileDirectory = new DirectoryInfo(folderBrowserDialog1.SelectedPath); //FileInfo\[\] FilesFromDirectory = FileDirectory.GetFiles(); FileInfo\[\] FileJpg = FileDirectory.GetFiles("\*.jpg"); FileInfo\[\] FileGif = FileDirectory.GetFiles("\*.gif"); FileInfo\[\] FileBmp = FileDirectory.GetFiles("\*.bmp"); FileInfo\[\] FileTif = FileDirectory.GetFiles("\*.tif"); FileInfo\[\] FilePng = FileDirectory.GetFiles("\*.png"); foreach (FileInfo File in FileJpg) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileTif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo
djsproject wrote:
FileInfo\[\] FileJpg = FileDirectory.GetFiles("\*.jpg"); FileInfo\[\] FileGif = FileDirectory.GetFiles("\*.gif"); FileInfo\[\] FileBmp = FileDirectory.GetFiles("\*.bmp"); FileInfo\[\] FileTif = FileDirectory.GetFiles("\*.tif"); FileInfo\[\] FilePng = FileDirectory.GetFiles("\*.png"); foreach (FileInfo File in FileJpg) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileTif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FilePng) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); }
This is WTF. Use at least the following solution please:
string[] extensions = new string[] {"jpg", "gif", "bmp", /*...*/};
foreach (string extension in extensions)
{
FileInfo[] FileJpg = FileDirectory.GetFiles(string.Format("*.{0}", extension));
foreach (FileInfo File in FileJpg)
{
ImageList.Add(File.Name, File.FullName);
checkedListBox1.Items.Add(File.Name);
}
}Also, set meaningful names for your controls, please. e.g. change 'button1' to 'buttonAddImage' or sth.
Greetings - Jacek
-
djsproject wrote:
FileInfo\[\] FileJpg = FileDirectory.GetFiles("\*.jpg"); FileInfo\[\] FileGif = FileDirectory.GetFiles("\*.gif"); FileInfo\[\] FileBmp = FileDirectory.GetFiles("\*.bmp"); FileInfo\[\] FileTif = FileDirectory.GetFiles("\*.tif"); FileInfo\[\] FilePng = FileDirectory.GetFiles("\*.png"); foreach (FileInfo File in FileJpg) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileGif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FileTif) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); } foreach (FileInfo File in FilePng) { ImageList.Add(File.Name, File.FullName); checkedListBox1.Items.Add(File.Name); }
This is WTF. Use at least the following solution please:
string[] extensions = new string[] {"jpg", "gif", "bmp", /*...*/};
foreach (string extension in extensions)
{
FileInfo[] FileJpg = FileDirectory.GetFiles(string.Format("*.{0}", extension));
foreach (FileInfo File in FileJpg)
{
ImageList.Add(File.Name, File.FullName);
checkedListBox1.Items.Add(File.Name);
}
}Also, set meaningful names for your controls, please. e.g. change 'button1' to 'buttonAddImage' or sth.
Greetings - Jacek
hey i want this code of rotating image with all the images that i have selected can somebody tell me how to get it done?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;namespace ImageRotation
{
public partial class Form1 : Form
{
private Image loadedImage;public Form1() { InitializeComponent(); } private Image RotateImage(Image inputImg, double degreeAngle) { //Corners of the image PointF\[\] rotationPoints = { new PointF(0, 0), new PointF(inputImg.Width, 0), new PointF(0, inputImg.Height), new PointF(inputImg.Width, inputImg.Height)}; //Rotate the corners PointMath.RotatePoints(rotationPoints, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f), degreeAngle); //Get the new bounds given from the rotation of the corners //(avoid clipping of the image) Rectangle bounds = PointMath.GetBounds(rotationPoints); //An empy bitmap to draw the rotated image Bitmap rotatedBitmap = new Bitmap(bounds.Width, bounds.Height); using (Graphics g = Graphics.FromImage(rotatedBitmap)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; //Transformation matrix Matrix m = new Matrix(); m.RotateAt((float)degreeAngle, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f)); m.Translate(-bounds.Left, -bounds.Top, MatrixOrder.Append); //shift to compensate for the rotation g.Transform = m; g.DrawImage(inputImg, 0, 0); } return (Image)rotatedBitmap; } private void trackBar1\_Scroll(object sender, EventArgs e) { if (loadedImage != null) pictureBox1.Image = RotateImage(loadedImage, (double)tRotation.Value); pictureBox1.Refresh(); } private void btnLoad\_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) {