|
I am getting an error when try to debug:
System.ArgumentOutOfRangeException was unhandled by user code
Message="Index and count must refer to a location within the buffer.\r\nParameter name: bytes"
Source="mscorlib"
ParamName="bytes"
StackTrace:
at System.Text.ASCIIEncoding.GetString(Byte[] bytes, Int32 byteIndex, Int32 byteCount)
at GetImage.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\jc\My Documents\Visual Studio 2005\WebSites\CashApp\Cash\GetImage.aspx.cs:line 50
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
|
|
|
|
|
Like the error message says...
tempStream = new MemoryStream(
imageBytes, oleOffset, imageBytes.Length - oleOffset);
I'd say this is wrong. Certainly somewhere you're using values that don't index into the data as they should.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
there are columns called FrontImageOffset, FrontImageSize that tells me where an image's byte stream ends and a new image begins
so, I am using a sql command like below to figure out what I am supposed to looking for..
sql = "select FrontImageOffset, FrontImageSize from CDData where TransactionId=" + TransactionId;
using (SqlCommand cmd = new SqlCommand(sql, cn))
|
|
|
|
|
Well, it's obvious that somewhere you are trying to pass an array index that is outside the bounds of the array. Maybe it's not this line, I didn't look through your code closely.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Here is the revised question.
I have two table: data and image talbe.
Data table
Transactionid documenttype frontimage offset frontimage size
1934318415 CHECK 1 11264
1934318415 COUP 18433 27648
1934318415 COUP 57345 39936
The front/rear offset tell you where the image data in image table begins and the front/rear length tell you how many bytes from the offset to extract to get the image out of the .
Image table..
Image table
Transaction ID, Image
1934318415 <binary>
Below id the logic that I am going to use to retrive the images. Can you help me out writing a code?
//
// Write the logic to retrieve the byte array from the Image table
// … … … …
MemoryStream ImageStream = new MemoryStream (Byte_Array_From_Image_Table);
// You allocate a buffer to hold the image in
Byte[] bytes = new Byte[FrontImageSize + RearImageSize];
int offset = Convert.ToInt32(FrontImageOffset) - 1;
// Move the pointer in your stream to offset position and then read
ImageStream.Seek(offset, SeekOrigin.Begin);
ImageStream.Read(bytes, 0, bytes.Length);
// Create a image object from that buffer
Bitmap bmp = new Bitmap(new MemoryStream(bytes));
// retrive image
-- modified at 16:55 Thursday 12th January, 2006
|
|
|
|
|
Jusah has told me to use double buffering.
But i don't make draw inside the panel i just move it and when i move it flicker.
So how can use double buffer on this?
|
|
|
|
|
By turning on double buffering.
this.SetStyle(ControlStyles.DoubleBuffer, true);
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You can't use double buffering in this instance except for the containing Form and I don't think that will solve your problem.
I don't know if this applies to the situation, but what kind of hardware do you have in your computer? I just built a mock application such as you describe with a moving panel that simulates scrolling. I put a TrackBar on the form next to the panel to adjust the panel's Top property. I then scrolled the heck out of the picture; on my newest computer, it does not flicker. On an older PC with limited video memory, the image shears as I scroll.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
i get a P4 3,2 ghz with 512mb ram and a Ati radeon 9550
Anyway it continue to flicker and when i move it fliker other unmoved controlls too.
|
|
|
|
|
I don't see that on my implementation. I'm sorry. I wish I could help more.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
thanks anyway
|
|
|
|
|
I have an application that animates a form with a transparent panel, i don't use Double Buffering and i had the same problem you are having. To be quite honest i'm not sure exactly what fixed the problem but here's the method i'm using to set the transparency, hopefully it'll work for you.
private void MakeTransparent()
{
Bitmap bitmap = (Bitmap)pnlBackground.BackgroundImage;
bitmap.MakeTransparent(bitmap.GetPixel(1, 1));
TransparencyKey = BackColor;
WindowState = FormWindowState.Normal;
}
The window starts minimised and then i bring it onto screen from this method which is called in Form_Load, otherwise i get a black border around my form. The panel pnlBackground is docked to the form. I don't do anything special when i'm annimating the form so if this doesn't help then post your code that mvoes your panel and i'll see if i can help.
Cheers
Kev
|
|
|
|
|
Hi,
If at some point in my code, if i re-set the combobox's dataset with a new datasource object, i see that the DisplayMember value gets blank automatically. Any ideas?
|
|
|
|
|
You need to set it again, obviously
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I know, so i have reset it again, but it still keeps it as blank.
string displayMember = theComboBox.DisplayMember; // Collect the DisplayMember value, because its going to be blank for some reason immediately after re-setting the DataSource.
theComboBox.DataSource = theNewDataSourceObjet;
theComboBox.DisplayMember = displayMember;
Now even though i have re-set the DisplayMember, it is still string.Empty.
Why???????
|
|
|
|
|
The combo box doesn't have a databind method ? the new data source has the same object available as a data source ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Its there. My point is why can't I simply set the control's DataSource property? Is there any special reason that i have to clear the bindings and then add a new binding. Why can't i simply re-set the data source propery and re-set the DisplayMember property straigt-away.
Just curious?
I want to know why's of this so it will help my fundamental understanding. Please help and clarify.
|
|
|
|
|
Setting a datasource does exactly that. But, the datasource is not actually used to do anything until you call DataBind. That's what the method is for, to create a gap between setting a source and using it, so you can set these other properties.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Chris. I get it now.
ONe other question - i am trying to filter teh combobox. When i reset the datasource such that the reset datasource now has less number of items than before. When the new data is displaed, the drop-list window keeps the original size (i.e. the size when it had more items in the list) although the current list is less and hence the drop-list looks pretty ugly, because there is more blank space visible in the drop-list than is neccessary to hold the new fewer items of data. If i manually click hte drop-down arrow to close the window and reopen it then the size is correctly refreshed.
So, I tried to simulate this in code by setting DroppedDown to false and then to true so that i could simulate it to close and re-open the list, but it does not fix the issue.
Is this a known bug in combobox control.
-- modified at 20:41 Wednesday 11th January, 2006
|
|
|
|
|
To be honest, I've never heard that one before, it could be a bug.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi!
if you want to filter your combobox, i suggest to use a dataview as your datasource.
then you can just past your filter to the RowFilter property of the dataview.
this will also solve your problem regarding the dropdown size and if ever you want to sort the items, you can set it to the Sort property of the dataview.
hope that helps!
|
|
|
|
|
Thanks and i will look into that too!
|
|
|
|
|
Hi,
I have a datagrid/datatable and when I click on a row, I want to see if it's already selected (so I can unselect it). What's the syntax for that?
Thanks,
Mel
|
|
|
|
|
Sorry, I didn't see it at first, but I stumbled upon the IsSelected method. Guess that makes sense.
Cheers,
Mel
|
|
|
|
|
if I have some sound Files , and I want to play them one after the other , the performance of hearing them not good because the time to call each one . So, I try to use a MemoryStream to make the sound files become a single group so, I will need only one call , but I failed to make it .
Then I used FileStream to create a sound file and I called it "sound.WAV" , and by using for loop append the sound files in "sound.WAV" , but only the first file appended
...............
I hope you to help me ... here my code after seeing your site .. Really it is a good site ...
//------- here my code --------
public class WAVSounds
{
[DllImport("WinMM.dll")]
public static extern bool PlaySound(byte[]wfname, int fuSound);
// flag values for SoundFlags argument on PlaySound
public int SND_SYNC = 0x0000; // play synchronously (default)
public int SND_ASYNC = 0x0001; // play asynchronously
public int SND_NODEFAULT = 0x0002; // silence (!default) if sound not found
public int SND_MEMORY = 0x0004; // pszSound points to a memory file
public int SND_LOOP = 0x0008; // loop the sound until next sndPlaySound
public int SND_NOSTOP = 0x0010; // don't stop any currently playing sound
public int SND_NOWAIT = 0x00002000; // don't wait if the driver is busy
public int SND_ALIAS = 0x00010000; // name is a registry alias
public int SND_ALIAS_ID = 0x00110000; // alias is a predefined ID
public int SND_FILENAME = 0x00020000; // name is file name
public int SND_RESOURCE = 0x00040004; // name is resource name or atom
public int SND_PURGE = 0x0040; // purge non-static events for task
public int SND_APPLICATION = 0x0080; // look for application specific association
//--------------------------------------------------------------------
public WAVSounds()
{
}
//-------------------------------------------------------------------
~WAVSounds()
{
}
//-------------------------------------------------------------------
public void Play(string wfname,int SoundFlags)
{
byte[] bname = new Byte[256]; //Max path length
bname = System.Text.Encoding.ASCII.GetBytes(wfname);
PlaySound(bname,SoundFlags);
}
//--------------------------------------------------------------------
public void PlayMS(byte[] memory,int SoundFlags)
{
//PlaySound( memory, SND_MEMORY | SND_SYNC );
PlaySound( memory,SoundFlags);
}
//--------------------------------------------------------------------
public void StopPlay()
{
PlaySound(null,SND_PURGE);
}
//----------------------------------------------------------------------
} //End WAVSounds class
//----------------------------
//--- In my Button I wrote ---------
WAVSounds ws = new WAVSounds();
MemoryStream ms = new MemoryStream();
FileStream fsr;
FileStream fsw;
byte[] SoundBuffer = new byte[Max*Max];
//-------------------------------------------------------
// ----------- File Stream ----------
//*************************************
fsw = new FileStream(path+"sound.WAV", FileMode.Create, FileAccess.Write);
//fsw.Close();
int i=0;
//**************************************
// fsw = new FileStream("D:\\c\\Project\\agents\\New Designe\\TextToSpeach\\sound.WAV", FileMode.Append , FileAccess.Write);
fsr = new FileStream(Sound[i],FileMode.Open );
for(i=0;i
|
|
|
|