Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can I make my code modular? Pin
V.16-Oct-18 18:44
professionalV.16-Oct-18 18:44 
GeneralRe: How can I make my code modular? Pin
henrydevid127-Oct-18 11:56
henrydevid127-Oct-18 11:56 
AnswerRe: How can I make my code modular? Pin
#realJSOP24-Oct-18 1:42
mve#realJSOP24-Oct-18 1:42 
AnswerRe: How can I make my code modular? Pin
josda100026-Oct-18 18:29
josda100026-Oct-18 18:29 
GeneralRe: How can I make my code modular? Pin
josda100027-Oct-18 2:48
josda100027-Oct-18 2:48 
QuestionImagelist in Tabcontrol - Image selection Pin
RAFENS15-Oct-18 23:47
RAFENS15-Oct-18 23:47 
AnswerRe: Imagelist in Tabcontrol - Image selection Pin
BillWoodruff19-Oct-18 2:49
professionalBillWoodruff19-Oct-18 2:49 
QuestionImage processing in c# Pin
Member 1401942314-Oct-18 10:51
Member 1401942314-Oct-18 10:51 
Hi All,

I am new to C#,I have built a scanning application using C# in visual studio which scans images in black and white but I would like to add a comobox fpr colormode which has options such as Grayscale and color


Basically I am wanting to scan images in color How do I Implement it?

Thanks in Advance

I have used the following code



namespace WindowsApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ListScanners();

// Set start output folder TMP
textBox1.Text = Path.GetTempPath();
// Set JPEG as default
comboBox1.SelectedIndex = 1;

}

private void ListScanners()
{
// Clear the ListBox.
listBox1.Items.Clear();

// Create a DeviceManager instance
var deviceManager = new DeviceManager();

// Loop through the list of devices and add the name to the listbox
for (int i = 1; i <= deviceManager.DeviceInfos.Count; i++)
{
// Add the device only if it's a scanner
if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType)
{
continue;
}

// Add the Scanner device to the listbox (the entire DeviceInfos object)
// Important: we store an object of type scanner (which ToString method returns the name of the scanner)
listBox1.Items.Add(
new Scanner(deviceManager.DeviceInfos[i])
);
}
}

private void button1_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(StartScanning).ContinueWith(result => TriggerScan());
}

private void TriggerScan()
{
Console.WriteLine("Image succesfully scanned");
}

public void StartScanning()
{
Scanner device = null;

this.Invoke(new MethodInvoker(delegate()
{
device = listBox1.SelectedItem as Scanner;
}));

if (device == null)
{
MessageBox.Show("You need to select first an scanner device from the list",
"Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (String.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Provide a filename",
"Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

ImageFile image = new ImageFile();
string imageExtension = "";

this.Invoke(new MethodInvoker(delegate()
{
switch (comboBox1.SelectedIndex)
{
case 0:
image = device.ScanPNG();
imageExtension = ".png";
break;
case 1:
image = device.ScanJPEG();
imageExtension = ".jpeg";
break;
case 2:
image = device.ScanTIFF();
imageExtension = ".tiff";
break;
}
}));



var path = Path.Combine(textBox1.Text, string.Format(@"{0}", Guid.NewGuid()).Replace("-", "").ToUpper() + imageExtension);

if (File.Exists(path))
{
File.Delete(path);
}

image.SaveFile(path);



}
}

modified 14-Oct-18 20:42pm.

AnswerRe: Image processing in c# Pin
Dave Kreskowiak14-Oct-18 11:56
mveDave Kreskowiak14-Oct-18 11:56 
GeneralRe: Image processing in c# Pin
Member 1401942314-Oct-18 14:44
Member 1401942314-Oct-18 14:44 
GeneralRe: Image processing in c# Pin
Dave Kreskowiak14-Oct-18 18:28
mveDave Kreskowiak14-Oct-18 18:28 
QuestionUploading images to web hosting server (a particular folder like "Images") through C#.NET Pin
PKSubudhi13-Oct-18 17:47
PKSubudhi13-Oct-18 17:47 
AnswerRe: Uploading images to web hosting server (a particular folder like "Images") through C#.NET Pin
OriginalGriff13-Oct-18 19:56
mveOriginalGriff13-Oct-18 19:56 
AnswerRe: Uploading images to web hosting server (a particular folder like "Images") through C#.NET Pin
Mycroft Holmes14-Oct-18 13:04
professionalMycroft Holmes14-Oct-18 13:04 
QuestionHow can we send SMS in C#.NET to any mobile number without API Gateway? Pin
PKSubudhi13-Oct-18 19:53
PKSubudhi13-Oct-18 19:53 
AnswerRe: How can we send SMS in C#.NET to any mobile number without API Gateway? Pin
Richard MacCutchan13-Oct-18 21:24
mveRichard MacCutchan13-Oct-18 21:24 
AnswerRe: How can we send SMS in C#.NET to any mobile number without API Gateway? Pin
Dave Kreskowiak14-Oct-18 4:53
mveDave Kreskowiak14-Oct-18 4:53 
AnswerRe: How can we send SMS in C#.NET to any mobile number without API Gateway? Pin
MadMyche15-Oct-18 6:25
professionalMadMyche15-Oct-18 6:25 
GeneralRe: How can we send SMS in C#.NET to any mobile number without API Gateway? Pin
MadMyche1-Aug-19 5:35
professionalMadMyche1-Aug-19 5:35 
QuestionaForge.net question Pin
Member 1345929011-Oct-18 4:46
Member 1345929011-Oct-18 4:46 
AnswerRe: aForge.net question Pin
Bernhard Hiller11-Oct-18 21:39
Bernhard Hiller11-Oct-18 21:39 
QuestionHow to connect a mobile phone camera into asp.net c# webapplication without using a usb cable. Pin
Member 119849599-Oct-18 0:27
Member 119849599-Oct-18 0:27 
AnswerRe: How to connect a mobile phone camera into asp.net c# webapplication without using a usb cable. Pin
Nathan Minier9-Oct-18 1:33
professionalNathan Minier9-Oct-18 1:33 
AnswerRe: How to connect a mobile phone camera into asp.net c# webapplication without using a usb cable. Pin
OriginalGriff9-Oct-18 1:39
mveOriginalGriff9-Oct-18 1:39 
GeneralRe: How to connect a mobile phone camera into asp.net c# webapplication without using a usb cable. Pin
Richard MacCutchan9-Oct-18 5:27
mveRichard MacCutchan9-Oct-18 5:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.