如何将在后台画的图片(比如说电气图,用自己软件绘制),下发至单片机液晶显示;

解决方案 »

  1.   

    800 x 8 pixels Graphics::TBitmap *pBitmap = new Graphics::TBitmap;
    pBitmap->Width = 800;
    pBitmap->Height = 8;
    pBitmap->PixelFormat = pf8bit; TPicture *pPicture = new TPicture;
    pPicture->LoadFromFile("E:\\tt8_3.bmp");
    pBitmap->Canvas->Draw(0, 0, pPicture->Graphic); AnsiString strHex, str; TFileStream *fs = new TFileStream("e:\\icon.h", fmCreate);
    str = "const unsigned char ICON_STATUS[] = {\r\n";
    for (int m = 0; m < pBitmap->Width; m++)
    {
    BYTE byZm = 0;
    for (int n = 0; n < 8; n++)
    {
    Byte *p = (Byte*)pBitmap->ScanLine[n];
    if (p[m] == 0)
    {
    byZm |= 1 << n;
    }
    }
    strHex.sprintf("0x%02X,", byZm);
    str += strHex;
    if (((m + 1) % 16) == 0)
    {
    str += "\r\n";
    }
    }
    str += "\r\n};\r\n";
    fs->Write(str.c_str(), str.Length());
    delete fs; Canvas->Draw(0, 0, pBitmap); delete pBitmap;