Array de Image

24/09/2004 - 18:40 por Anonimo | Informe spam
Hola, estoy declarando una variable Image[] newImage;
Con un open file dialog estoy seleccionando VARIAS imagenes
mi código es algo así:

Image[] newImage;
int intCant, intPos;
string [] strPaginas;
ofdPaginas.ShowDialog();
strPaginas = ofdPaginas.FileNames;
intCant = strPaginas.Length;
if(intCant > 0)
{
for(intPos=0;intPos < intCant; intPos++)
{
newImage[intPos] = new Bitmap(strPaginas[intPos]);
}
}

Pero me da error al crear la nueva imagen,
An unhandled exception of
type 'System.NullReferenceException' occurred in
Digitalizacion.exe

Additional information: Object reference not set to an
instance of an object
 

Leer las respuestas

#1 Pedro Luna Montalvo, MVP
24/09/2004 - 22:04 | Informe spam
Saludos,

intCant = strPaginas.Length;
if(intCant > 0) {
newImage = new Image[intCant]; // <<<< Agrega esta linea!!
for(intPos=0;intPos < intCant; intPos++) {
newImage[intPos] = new Bitmap(strPaginas[intPos]);
}
}

Pedro Luna, MVP
Gye, Ecu


escribió en el mensaje
news:191b01c4a255$30888630$
Hola, estoy declarando una variable Image[] newImage;
Con un open file dialog estoy seleccionando VARIAS imagenes
mi código es algo así:

Image[] newImage;
int intCant, intPos;
string [] strPaginas;
ofdPaginas.ShowDialog();
strPaginas = ofdPaginas.FileNames;
intCant = strPaginas.Length;
if(intCant > 0)
{
for(intPos=0;intPos < intCant; intPos++)
{
newImage[intPos] = new Bitmap(strPaginas[intPos]);
}
}

Pero me da error al crear la nueva imagen,
An unhandled exception of
type 'System.NullReferenceException' occurred in
Digitalizacion.exe

Additional information: Object reference not set to an
instance of an object

Preguntas similares