|
Actually width and height in the bitmapdata object is equal to the rectangle I passed in which is just a part of the image, but not the image itself. I'm wondering if this can even work as we copy the array back into the image, only providing the start address. My guess is it will just start at that address and copy the array sequentially back into that image?
should I rather read in the entire image and only replace the pixels when I reach the index inside the rectangle?
pixelformat is set to 24 bpp.
In code I do something like this :
bmp = bmp.Clone(new System.Drawing.Rectangle(0,0, bmp.Width, bmp.Height),System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Since I never know what format the jpg/bmp file is.
Many thanks for your help (I'm new at this so I'm figuring it out as I go)
|
|
|
|
|
It may be hard to explain, as no images allowed here, but I will give a try...
When you are copy only the part of an bitmap image the byte array that you holds only the part you asked for - that obvious I think and expected too...
But! That also mean that you have to compute the stride for that part only, as the lock method will provide you with scans (lines) padded to stride and not of length of width!
You can compute the stride like this:
int bitsPerPixel = ((int)format & 0xff00) >> 8;
int bytesPerPixel = (bitsPerPixel + 7) / 8;
int stride = 4 * ((width * bytesPerPixel + 3) / 4);
You may consider one of these options too:
1. Lock all the bitmap and use x,y,width,height as an index inside it (no extra computations of stride as BitmapInfo already have it)
2. Create a new bitmap out of the wanted portion and go back to 1
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I think you just verified what I was thinking
thanks!
|
|
|
|
|
Anyone please explain c# classes in detail with examples.
|
|
|
|
|
Nobody's going to take the time to explain that to you. You'll have to take the trouble to get your head around it yourself. Here's a start: Object-Oriented Programming Principles[^] (video).
/ravi
|
|
|
|
|
|
This keeps appearing my in program everytime I run it, I really do not understand this
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
the error appears to be where it says "new Form1" then appears to say that Input String was in the incorrect format
|
|
|
|
|
That's standard boilerplate code to start a Windows Forms app and has absolutely nothing to do with your error.
It appears as though you have a problem converting a string to some data type, but there isn't enough information to narrow it down beyond this.
|
|
|
|
|
Don't tell us what the error appears to say; copy the full details of the exception and post that. There's a link in the Visual Studio exception helper dialog to "copy exception details to the clipboard".
If the exception is occurring in the constructor of Form1 , then you'll need to post the code for that as well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In addition to Richards comments about the Form1 constructor, you may want to look at any static fields you have declared, as they are likely to be initialized around then as well.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I retrive the row from database using sql dataadapter in datatable
it works well for sometime.But some times it throws no column found exception.
I dont know what excatly problem is their it sometimes work & sometime throw an exception for same data.
|
|
|
|
|
For the time it does not work, please post the relevant code and/or SQL to let us examine it...It will be also useful to let us know what column not found...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
string query = "SELECT A.emp_id, A.emp_first_name, A.emp_last_name, B.vehicle_no FROM (SELECT emp_id, emp_first_name, emp_last_name FROM emp_detail WHERE (emp_id = (SELECT emp_id FROM Tag_Assign WHERE(Tag_no =(select tag_no from tag_master where tag_id='" + textBox2.Text.Trim() + "'))))) AS A CROSS JOIN (SELECT emp_id, vehicle_no FROM Tag_Assign AS Tag_Assign_1 WHERE(Tag_no =(select tag_no from tag_master where tag_id='" + textBox2.Text.Trim() + "'))) AS B";
DataTable dt = con.datasource(query.Trim());
if (dt.Rows.Count > 0)
{
lblEmp_name.Text = dt.Rows[0][1].ToString() + " " + dt.Rows[0][2].ToString();
lblVehicle_no.Text = dt.Rows[0][3].ToString();
}
In above code it gives exception at dt.Rows[0][0].ToString();
|
|
|
|
|
Possibly dt.Rows[0][0] is null. Debug it!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
dt.Rows[0][0] contains employee id but as i metioned earlier it sometime throws exception
|
|
|
|
|
So get your feet wet! Catch the case when it throws exception and check if it is null!!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
It catches IndexOutOfRange Exception .Can not find column 1
|
|
|
|
|
It only contains something if something can be found.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Your code is susceptible to SQL Injection[^]. You should change it to use a parameterised query. How easy that is to do will depend on the implementation of your custom datasource method.
You can also simplify your query quite significantly:
SELECT
ED.emp_id,
ED.emp_first_name,
ED.emp_last_name,
TA.vehicle_no
FROM
emp_detail As ED
INNER JOIN Tag_Assign As TA
ON TA.emp_id = ED.emp_id
INNER JOIN tag_master As TM
ON TA.Tag_no = TM.tag_no
WHERE
TM.tag_id = @tag_id
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank u so much for helping me out now its working. Thanks again
|
|
|
|
|
Hello Guys,
Am developing an EXE for Coundowntimer functionality, I have used the below code for creating countdowntimer.
In Present Code: We need to give input for the "Time" and then start the timer in the output dialog
(Please refer the attached file)
Am planning to implement a app.config for Countdowntimer.exe, so that i can give my time directly in Countdowntimer.config and when i run my Countdowntimer.exe, the timer automatically will pick the time details given in Countdowntimer.config as input and start the timer.
my present code:
namespace countdownTimer
{
public partial class Form1 : Form
{
public int seconds; // Seconds.
public int minutes; // Minutes.
public int hours; // Hours.
public bool paused; // State of the timer [PAUSED/WORKING].
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
if (paused != true)
{
if ((textBox1.Text != "") && (textBox2.Text != "") && (textBox3.Text != ""))
{
timer1.Enabled = true;
button2.Enabled = false;
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
try
{
minutes = System.Convert.ToInt32(textBox2.Text);
seconds = System.Convert.ToInt32(textBox3.Text);
hours = System.Convert.ToInt32(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
MessageBox.Show("Incomplete settings!");
}
}
else
{
timer1.Enabled = true;
paused = false;
button2.Enabled = false;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
// Verify if the time didn't pass.
if ((minutes == 0) && (hours == 0) && (seconds == 0))
{
// If the time is over, clear all settings and fields.
// Also, show the message, notifying that the time is over.
timer1.Enabled = false;
button2.Enabled = true;
textBox3.Clear();
textBox2.Clear();
textBox1.Enabled = true;
textBox3.Enabled = true;
textBox2.Enabled = true;
textBox1.Enabled = true;
lblHr.Text = "00";
lblMin.Text = "00";
lblSec.Text = "00";
}
else
{
// Else continue counting.
if (seconds < 1)
{
seconds = 59;
if (minutes == 0)
{
minutes = 59;
if (hours != 0)
hours -= 1;
}
else
{
minutes -= 1;
}
}
else
seconds -= 1;
// Display the current values of hours, minutes and seconds in
// the corresponding fields.
lblHr.Text = hours.ToString();
lblMin.Text = minutes.ToString();
lblSec.Text = seconds.ToString();
}
}
private void button3_Click(object sender, EventArgs e)
{
// Stop the timer.
paused = false;
timer1.Enabled = false;
button2.Enabled = true;
textBox3.Clear();
textBox2.Clear();
textBox1.Clear();
textBox1.Enabled = true;
textBox3.Enabled = true;
textBox2.Enabled = true;
textBox1.Enabled = true;
lblHr.Text = "00";
lblMin.Text = "00";
lblSec.Text = "00";
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Please suggest how do i provide a the input to the timer Hr: Min: Sec using app.config file.
-- modified 19-Jul-14 7:18am.
|
|
|
|
|
In your configuration file, you can add following section:
<appSettings>
<add key ="SomeKey" value="Somevalue"/>
</appSettings>
In code, you can access it using this line:
string valueFromConfig = ConfigurationManager.AppSettings["SomeKey"];
For more complex values in configuration, you can create your own configuration section and use that.
|
|
|
|
|
How to create Virtual Drive in c#?
|
|
|
|
|
|
Like this[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|