I improved a lot on my old sources by checking many questions.
I changed it to C++ source by referring to the link.
I confirmed that it takes a long time to print the image when using 24 dots.
I found out that the solution to this problem is to change it to 8dot.
8dot image If you set it to 24dot, it will be printed normally. 24dot image
I'd like to know if I'm missing anything.
CString GetLogo(LPCTSTR fileName)
{
CString csFileName = fileName;
csFileName = csFileName.MakeUpper();
BitmapData data = GetBitmapData(csFileName.GetBuffer());
std::vector<bool>& dots = data.Dots;
unsigned char widthLow = static_cast<unsigned char>(data.Width & 0xFF);
unsigned char widthHigh = static_cast<unsigned char>((data.Width >> 8) & 0xFF);
int offset = 0;
CString result;
result.AppendChar((char)0x1B);
result.AppendChar('@');
result.AppendChar((char)0x1B);
result.AppendChar('3');
result.AppendChar((char)8);
while (offset < data.Height)
{
result.AppendChar((char)0x1B);
result.AppendChar('*');
result.AppendChar((char)1);
result.AppendChar((char)widthLow);
result.AppendChar((char)widthHigh);
for (int x = 0; x < data.Width; ++x)
{
unsigned char slice = 0;
for (int b = 0; b < 8; ++b)
{
int y = offset + b;
int i = (y * data.Width) + x;
bool v = (i < (int)dots.size()) ? dots[i] : false;
slice |= (unsigned char)((v ? 1 : 0) << (7 - b));
}
result.AppendChar((char)slice);
}
offset += 8;
result.AppendChar((char)0x0A);
}
result.AppendChar((char)0x1B);
result.AppendChar('3');
result.AppendChar((char)30);
return result;
}