TBitmap aus Array erstellen
-
Ach so, das sollte klappen:
Image->Picture->Bitmap->PixelFormat = pf12bit;
Sorry, hatte momentan nicht dran gedacht.
-
so weit ich weis gibts aber nur pf8bit und dann pf15bit (16,24,32)...
-
Erstmal danke für die Antworten,
das Problem ist aber doch, wenn ich Pixel für Pixel in einem Canvas setze, dass das langsam ist. Daher wolte ich halt zuerst ne Bitmap. Das 8, 12bit Problem ist keins. Ich hab die 12bit auf 8bit runtergebishiftet, da mit 256 Graustufen ausreichen.
Btw.: Wieso kann ich kein TBitmap in einer Klasse erstellen? Ich bekomme dann folgenden Fehler:
E2015 Ambiguity between 'TBitmap' and 'Windows::TBitmap'Das hindert mich am Herumprobieren...
-
Für schnelleren Zugriff solltest du ScanLine statt Pixels benutzen.
Die Mehrdeutigkeit kannst du umgehen, indem du explizit Graphics::TBitmap verwendest. Diese Information hättest du übrigens auch den verschieden Beispielen in der Hilfe zu TBitmap entnehmen können.
-
geht das nicht auch so? (Naja geht noch nicht, sonst würd' ich nicht fragen)
TMemoryStream* pMemStream = new TMemoryStream; pMemStream->Write(data8bit.pixeldata, 640*480); pBmp = new Graphics::TBitmap; pBmp->LoadFromStream(pMemStream); pImage->Assign(pBmp);
Beim Assign stürzt er ab. pImage->Picture->Bitmap=pBmp; geht auch nicht. Weiss vielleicht jemand wie das geht, oder kann mir sagen, wo ich in der Hilfe was finde.
Danke!
-
Hi,
nur so eine Vermutung:pImage->Picture->Assign(pBmp);
Alexander Sulfrian
-
Hi,
geht auch...
pImage->Picture = pBmp; // property Picture void __fastcall TImage::SetPicture(TPicture *Value) { FPicture->Assign(Value); }
-
Falls es jemanden interessiert, hier meine Lösung:
class C8bitTIFFData { public: unsigned int width; unsigned int height; unsigned char pixeldata[IMAGE_SIZE]; }; void CTIFFImage::Plot(TImage* pImage) { TBitmapFileHeader *BitmapFileHeader = new TBitmapFileHeader; BITMAPINFO_8BPP *BitmapInfo = new BITMAPINFO_8BPP; BitmapFileHeader->bfType=19778; BitmapFileHeader->bfSize=sizeof(TBitmapFileHeader) + sizeof(TBitmapInfo) + 640*480; BitmapFileHeader->bfReserved1=0; BitmapFileHeader->bfReserved2=0; BitmapFileHeader->bfOffBits=sizeof(TBitmapFileHeader) + sizeof(TBitmapInfo); BitmapInfo->bmiHeader.biSize=sizeof(TBitmapInfoHeader); BitmapInfo->bmiHeader.biWidth=640; BitmapInfo->bmiHeader.biHeight=480; BitmapInfo->bmiHeader.biPlanes=1; BitmapInfo->bmiHeader.biBitCount=8; BitmapInfo->bmiHeader.biCompression=BI_RGB; BitmapInfo->bmiHeader.biSizeImage=640*480; BitmapInfo->bmiHeader.biXPelsPerMeter=0; BitmapInfo->bmiHeader.biYPelsPerMeter=0; BitmapInfo->bmiHeader.biClrUsed=0; BitmapInfo->bmiHeader.biClrImportant=0; for (int i=0; i<256; i++) { BitmapInfo->bmiColors[i].rgbBlue=i; BitmapInfo->bmiColors[i].rgbGreen=i; BitmapInfo->bmiColors[i].rgbRed=i; } TMemoryStream* pMemStream = new TMemoryStream; pMemStream->Write(BitmapFileHeader, sizeof(TBitmapFileHeader)); pMemStream->Write(BitmapInfo, sizeof(BITMAPINFO_8BPP)); pMemStream->Write(data8bit.pixeldata, 640*480); pMemStream->Position = 0; Graphics::TBitmap *pBmp = new Graphics::TBitmap(); pBmp->LoadFromStream(pMemStream); pImage->Picture->Bitmap=pBmp; delete pBmp; delete pMemStream; delete BitmapInfo; delete BitmapFileHeader; }
-
Das hier gehört noch dazu, die Klasse 8bitTIFFData ist ausversehen anstelledessen hereingerutscht.
typedef struct { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[256]; } BITMAPINFO_8BPP;
-
Sowas edles interessiert immer - zumindest den ich :p . FAQ-verdächtig. Und das nach so spärlichen Startinfos.