I have an Array of RGB-Byte-Informations of type Byte*.
I can save it using the corona-library to an PNG-File.
However, I would like to display the Bytearray somehow on a TImage-Object without having to save and load a file every time…
I have already found the solution of memorystream
Byte* pBuffer;//data
long cbBuffer;//length of data
TMemoryStream *tmem=new TMemoryStream();
tmem->Write(pBuffer,cbBuffer);
TPngImage *saf=new TPngImage();
saf->LoadFromStream(tmem);
However this complains about missing header as the bytearray doesn’t have a header.
So, I thought about creating a blank picture and drawing the pixelinformations on there…
Graphics::TBitmap *Bitmap = new Graphics::TBitmap();
Bitmap->Width = pVih->bmiHeader.biWidth;
Bitmap->Height = pVih->bmiHeader.biHeight;
for(int j=0;j<pVih->bmiHeader.biHeight;j++){
Byte* y=(Byte*) Bitmap->ScanLine[j];
for(int x=0;x<pVih->bmiHeader.biWidth;x++)
y[x]=pBuffer[j*pVih->bmiHeader.biWidth+x];
}
Image1->Picture->Graphic=Bitmap;
Application->ProcessMessages();
However, this stays blank. And I don’t really like painting pixels, even with the little faster ScanLine…
So, does anybody know how to display an Bytearray of colors in an TImage-Object?
If there is a neat library you can also advice it, but I tried to use pnglib several times and I don’t seem to figure out how to use it.
I’m using C++Builder from Embarcadero’s XE2 16.
Regards,
Julian
In Hindsight it might have been necessary to tell that I’m receiving a pf24Bit-picture…
And, of course, as it’s not one but 3 bytes per pixel there is a missing factor 3:
It’s still a bit slow, but I guess I can’t have direct access to the color-bytes within the bitmap…