|
Nope, it doesn't change a thing to the image.
|
|
|
|
|
I can't be sure, but it seems that something is wrong with the indexing of your buffer, I mean you write at the wrong positions...Review you calculations...
(If you got nowhere I have no objection that mail me with your project and a simple image too, I will do my best to see into it ASAP)
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Just tried with a real color image and that turned green entirely .
Could it be that the jpg has some sort of "grayscale" flag that is copied to the bitmap properties?
I'll try to not bug you too much with this, it's my job to figure it out, I was just hoping to get a lead.
(And you were great help so far, so thanks for that)
(the goal is that I open a scanned image and highlight features on it for surface calculation. The image "looks" grayscale since they are pencil drawings of sunspots[^].)
|
|
|
|
|
It can be that your image is indexed with some color table. In that case every color will be converted to the closest entry in that table...
You may create an new - non indexed - image of the proper size, than copy (http://msdn.microsoft.com/en-us/library/aa457087.aspx[^]) the original over it...In this way you will get the same image as a non indexed...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
And it turns green !
I added the following function:
private System.Drawing.Bitmap CreateNonIndexedImage(System.Drawing.Bitmap bmp){
System.Drawing.Bitmap newbmp = new System.Drawing.Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(newbmp);
g.DrawImage(bmp, 0, 0);
return newbmp;
}
but I overlooked the fact I reload a temp image when performing the lockbits part .
thanks for the help, I really appreciate it!
Now to just highlight the rectangle insteacd of the entire image
|
|
|
|
|
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 problem is that stride and width are not the same. Width is the actual width of the image in pixels but stride is the number of bytes a single image line takes, rounded up to multiplies of 4...
You also have to see into Pixel format, it may be different from simple RGB and in that case your loop writes wrong positions and/or wrong colors...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
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[^]
|
|
|
|