I'm creating an application on Android using C++ Builder, and I need to print out (not display on screen) a Bitmap already created. To print out, I'm using "Classic Bluetooth Basic App" that Embarcadero offers. To convert I'm using this code:
#include "System.NetEncoding.hpp"
TMemoryStream *ms;
TStringStream *ss;
String s;
UnicodeString result;
ms = new TMemoryStream();
ss = new TStringStream();
bmpResult->SaveToStream(ms);
ms->Position = 0;
EncodeStream(ms, ss);
s = ss->DataString;
ms->Free();
ss->Free();
result = s;
return result;
It returns to me the base64 string, so I could pass it in print out function, but it will print the whole string, and I need the bitmap (the image in itself).
How can I do it?
EDITED:
The code that I'm using to interact with the printer:
TBytes ToSend;
if((FSocket == NULL) || (ItemIndex != ComboBoxPaired->ItemIndex)) {
if(ComboBoxPaired->ItemIndex > -1) {
TBluetoothDevice * LDevice = FPairedDevices->Items[ComboBoxPaired->ItemIndex];
FSocket = LDevice->CreateClientSocket(StringToGUID(ServiceGUI), false);
if(FSocket != NULL) {
ItemIndex = ComboBoxPaired->ItemIndex;
FSocket->Connect();
//func is AnsiString and passed as a parameter in this function
ToSend = TEncoding::UTF8->GetBytes(func);
FSocket->SendData(ToSend);
delete FSocket;
FSocket = NULL;
}
else {
ShowMessage("Error 1");
}
}
else {
ShowMessage("Error 2");
}
}
else {
ShowMessage("Error 4");
}
I tried to use TEncoding
to encode the bitmap and pass to ToSend
, but I couldn't found and doesn't make sense because it will print the String (same case as base64).