BMP保存成string再进行显示

∥☆過路亽.° 提交于 2020-02-01 05:55:38
    ifstream in("c:\\Greenstone.bmp", ios::in|ios_base::binary);
    string s = string((istreambuf_iterator<char>(in)), istreambuf_iterator<char>());
    TMemoryStream* ms = new TMemoryStream();
    ms->Write(s.c_str(), s.length());
    ms->Position = 0;
    in.close();
    Graphics::TBitmap* bitmap = new Graphics::TBitmap();
    bitmap->LoadFromStream(ms);
    this->Image1->Canvas->StretchDraw(Rect(0,0,this->Image1->Width, this->Image1->Height), bitmap);
    delete bitmap;
    bitmap = 0;
    delete ms;
    ms = 0;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!