bilder anzeigen
-
Hallo Leute, ich hab ein kleines Problem mit der Bildanzeige. Ich schreibe die Grauwerte von einem Array in ein Bitmap-Bild und will dieses dann darstellen. Es funktioniert aber nur, wenn ich zuvor ein TImage gezeichnet habe. Wie kann ich dynamisch mehrere Bilder darstellen?
Der nachfolgende Code für die Umwandlung funktioniert, aber die Darstellung nicht.void __fastcall TMain::Button1Click(TObject *Sender) { TImage *Image1 = new TImage(this); Graphics::TBitmap *cPicture = new Graphics::TBitmap(); cPicture->Height = array->pixRow; cPicture->Width = array->pixCol; cPicture->PixelFormat = pf24bit; PRGBTriple ptr; float rgb=0; int x=0, y=0; BYTE *RGB; ptr = static_cast<PRGBTriple>(cPicture->ScanLine[y]); for(int i=0; i < (cPicture->Height * cPicture->Width); i++) { Form1->ProgressBar1->Position = i; if(x == cPicture->Width) { y++; x = 0; ptr = static_cast<PRGBTriple>(cPicture->ScanLine[y]); } rgb = ColorToRGB(array->getFeature(i, 0)); //Werte werden aus einem Array ausgelesen RGB = reinterpret_cast<BYTE*>(&rgb); ptr[x].rgbtBlue = RGB[0]; ptr[x].rgbtGreen = RGB[1]; ptr[x].rgbtRed = RGB[2]; x++; } Image1->Left = 10; Image1->Top = 130; Image1->Width = 105; Image1->Height = 105; Image1->Stretch = true; Image1->Proportional = true; Image1->Picture->Assign(cPicture); Image1->Refresh(); }
Vielen Dank, Mattias
-
Hmmm naja, den FAQ-Artikel kennst du zum Thema dynamischen Erstellen von Komponenten?
-junix
-
Danke habs gefunden!