Bitmap Array
-
Hallo,
ich möchte einer Methode ein Bitmap Array als Parameter übergeben.
Bei mir funktioniert das nicht.Bitmap[] bmp_temp = new Bitmap[4];
Bitmap bmp_ret;
Methodenaufruf:bmp_ret = bmpManager.AddBitmaps(ref bmp_temp);
Methode:
class BitmapManager { internal Bitmap AddBitmaps(Bitmap ref bmpBitmap) { Bitmap bmp_temp = null; int i_pixleft = -1, i_pixright = -1; try { for (int x = 0; x < bmpBitmap[0].Width; x++) { for (int y = 0; y < bmpBitmap[0].Height; y++) { Color temp = bmpBitmap[0].GetPixel(x, y); //Linkestes Pixel des Zeichens suchen if (i_pixleft == -1) if (temp == Color.Black) i_pixleft = x; //if (temp == clr_old) // bmpBitmap.SetPixel(x, y, clr_new); } } } catch { } return bmp_temp; } }
Die Fehlermeldung: Das Schlüsselwort "ref" gibts nicht und ohne "ref" gehts auch nicht.
mfG.
-
geht ohne ref
-
Aber wie?
Fehler 2 Die beste Übereinstimmung für die überladene TFT320_Configurator.BitmapManager.AddBitmaps(System.Drawing.Bitmap)-Methode hat einige ungültige Argumente.
Wie sieht hier das Argument aus wenns gültig sein soll?
mfG.
-
Die Fehlermeldung ist nicht vollständig. Sie sagt Dir noch was sie erwartet und was Du ihr gibst.
-
Hallo,
eine Bitmap Variable (Bitmap bmp_tem) geht als Übergabeparameter,
eine Bitmap Array (Bitmap[] bmp_temp = new Bitmap[4]) nicht.Es liegt nicht am Schlüsselwort "ref".
Wie würdesd Du den Methodenaufruf und die Methode schreiben?
mfG.
-
Ich bin mir jetzt unschlüssig ob ich die Frage nicht verstehe oder Dir die Grundlagen fehlen. Ich gehe mal davon aus, dass Du "beliebig viele" Bilder hinzufügen möchtest.
Deine Methode kann doch überhaupt kein Array verarbeiten. Für die Signatur gibt es 2 Möglichkeiten:
internal Bitmap AddBitmaps(Bitmap[] bmpBitmap) AddBitmap(bitmaparray);
oder
internal Bitmap AddBitmaps(params Bitmap[] bmpBitmap) AddBitmap(bitmaparray); oder AddBitmap(Bitmap1,Bitmap2,....,BitmapN);
-
Mal unabhänging davon was du vor hast. Die Syntax ist hier anders:
internal Bitmap AddBitmaps(ref Bitmap bmpBitmap)
sonst denkt Dein compiler, dass ref ein Identifier ist.
Grantopalen.