|
have a look at this[^] You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Actually that is where i knew how to convert and image to bytes but the function returning an Image, how will the pictureBox get the URL? Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Why would the picture box want a URL? Just give it the image, or save it to disk and then give it the url as the file location.
From your original code:
MemoryStream ms = new MemoryStream(byteArrayIn);
pictureBox1.Image = Image.FromStream(ms);
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Here you go:
MemoryStream memStream = new MemoryStream(imageBytes);
Image image = Image.FromStream(memStream);
|
|
|
|
|
Thanks guys. It worked. Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
try following code:
private void Button2_Click(object sender, System.EventArgs e)
{
connection.Open();
SqlCommand command1 = new SqlCommand("select imgfile from myimages where imgname=@param", connection);
SqlParameter myparam = command1.Parameters.Add("@param", SqlDbType.NVarChar, 30);
myparam.Value = txtimgname.Text;
byte[] img = (byte[])command1.ExecuteScalar();
MemoryStream str = new MemoryStream();
str.Write(img, 0, img.Length);
Bitmap bit = new Bitmap(str);
Response.ContentType = "image/jpeg";//or you can select your imagetype from database or directly write it here
bit.Save(Response.OutputStream, ImageFormat.Jpeg);
connection.Close();
}
change your database name, field name, image name, attribute name.
If You Get your answer then please Rating me...
Thanks..
"Are You Ready"
DX-ARMY
|
|
|
|
|
As you have seen system encodings, ASCII or UTF. I want to create my own, like some value for some specific character. So to do that I simple make a Character class and a collection to hold 'em. But when I need to convert a value to char it iterates the collection until that value is found and thats too slow. But I have another idea which I have tried and also reached nearby the same performance as Encoding.GetString.
So any suggestions guys ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
If it is a small set of values then set up an array of translations - index is the character to translate.
If the set gets big, then put the array into a file and read it on start up. You would need two arrays if you want to go both ways.
Memory is not a major problem these days, so that would be the fastest way.You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
thats exactly what I thought but there is a problem, It will be faster from value(index) to char but what about char to value ??
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You can also index an array with a char, or isn't that what you meant?
|
|
|
|
|
example ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
inverseArray[someChar]
Where someChar is of the type char and inverseArray is an array of something
|
|
|
|
|
That's why I said "You will need two arrays..." One for each direction? You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
you mean like this ?
short[] values = new short[count];
short[] chars = new short[count];
values[(int)'c'] = value;
chars[value] = 'c';
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You don't need to cast the char to an int
|
|
|
|
|
its not dictionary, its an array
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
It doesn't matter, indexing an array with a char works just as well
|
|
|
|
|
nice, never noticed.
Thanks btw
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Works fins just with a char:
int[] array = new int[256];
Random r = new Random();
for (int i = 0; i < 256; i++)
{
array[i] = r.Next(256);
}
string s = "Hello there!";
int[] output = new int[s.Length];
int ind = 0;
foreach (char c in s)
{
output[ind++] = array[c];
}
}
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
yupp thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
hellow
i m in a prob.
i hav a datagrid which has 3 columns.All the cell in first column will be in combobox when the form loads. but when the user selects a data from the combo then the Datagridcombo must be changed into datagridtextbox and selected data will be shown in the datagrid text box.
as well as the next row will show the datagridcombo in first column.
i need solution with code snippet.
thanks in advance and sorry for poor english.
Thanks
Tanim
|
|
|
|
|
I'm trying to stop a waitcallback in a threadpool within an event handler for a stop button. I've searched and searched and have not found a way to do this. Please help!
private void startbutton_Click(object sender, EventArgs e)
{
WaitCallback doLoadSequential = new WaitCallback this.loadsequential);
ThreadPool.QueueUserWorkItem(doLoadSequential);
}
private void stopbutton_Click(object sender, EventArgs e)
{
}
|
|
|
|
|
you need cooperative termination, e.g. add a volatile bool flag as a class member, set it false in startbutton_Click, set it true in stopbutton_Click, and test it regularly in doLoadSequential, so that method finishes as soon as the flag gets set.
|
|
|
|
|
Hi,
Let's say that I've a file and I would like to find a specific string's location inside it. It is logical to load my file into a byte array and then parse it into a string or a StringBuilder byte by byte, right? It is an easy issue if the file is small.
If the file is huge (like 400megabytes), it is not that easy. The application demands lots of RAM and it is annoying. I thought about copying the file into the byte array by 100 bytes, step by step. But this brings another problem, if the half of my string is inside the first 100 bytes, and the rest in the next 100 bytes; my application is not able to identify my string and therefore give its location to me.
How can I solve this, any ideas?
If there is anything unclear, feel free to ask.
Thanks.
|
|
|
|
|
Test it twice. First test it like usual, then test it again with the divisions offset by exactly half the batch size. As long as each batch is at least twice the size of the search string, you will be guaranteed to find the string in at least one of the two searches. More specifically, the offset MUST be less than or equal to Half the batch size AND greater than or equal to the size of the string being searched for.
|
|
|
|