Voici le problème :
J'essaye d'affecter plusieurs images arrivant d'un socket dans un picturebox. La fonction : CommencerRecevoirImage() est appelé par un thread. Le pictureBox est rempli parfaitement la première fois, tandis que par la suite, rien ne se passe. J'ai la confirmation que bDataAvailable est à true et que mon tableau a reçu des données.
Voici le code :
la variable suivante a été initialisé plus haut :
CStreaming* m_Stream;void CommencerRecevoirImage()
{
try
{
// des données valides sur le socket
bool bDataAvailable = false; unsignedchar ucTampon __gc[]; // lire le flux : The Port "127.0.0.1",L"3969"
ucTampon= m_Stream->Lire(bDataAvailable); if( bDataAvailable )
{
pictureBox2->Image = System:: Drawing::Image::FromStream(new System::IO::MemoryStream( ucTampon ));
}
}
catch (Exception* e)
{
MessageBox::Show(String::Concat(L"RecevoirImage ",e->Message));
}
}///**************** fonction appelé ************************///
const
int TAILLE_TAMPON_RECEPTION = 16384;
NetworkStream* m_Ns;
TcpClient* m_ClientTCP;
unsignedchar CStreaming::Lire(bool &bDataAvailable)__gc[]
{
// Receive the TcpServer::response.
bDataAvailable = false;
// Buffer to store the response bytes.
unsignedchar data __gc[]; data = newunsignedchar__gc[TAILLE_TAMPON_RECEPTION]; int bytes =0; // Read the first batch of the TcpServer response bytes. if( m_Ns->DataAvailable == true)
{
bytes = m_Ns->Read( data, 0, data->Length );
bDataAvailable = true;
} return data;
}void
CStreaming::Connection(String* ip, int port)
{
// Create a TcpClient.
m_ClientTCP = new TcpClient( ip,port ); m_Ns = m_ClientTCP->GetStream();
}void
CStreaming::Ecrire(unsignedchar data __gc[])
{
// Send the message to the connected TcpServer.
m_Ns->Write( data, 0, data->Length );
}
Mieux vaut être blonde et poser des questions que de rester ignorante !!!!