Skip to content

BUG:Android使用loadFromFile()无法加载图片 #4

@StephenLee9

Description

@StephenLee9

文件mgimagesp.cpp中:
bool MgImageShape::_save(MgStorage* s) const
{
s->writeString("name", _name);
s->writeFloat("imageWidth", _size.x);
s->writeFloat("imageHeight", _size.y);
LOGE("save() ----------> name = %s", _name); //打印结果:*.jpg
LOGE("save() ----------> _size.x = %f", _size.x); //打印结果:0.000000
LOGE("save() ----------> _size.y = %f", _size.y); //打印结果:0.000000
return __super::_save(s);
}
其中_name只包含图片的名称,不包含其路径,所以导致图片加载不出来
我把代码改为:
s->writeString("name", "/sdcard/image/img01.jpg");
s->writeFloat("imageWidth", 400);
s->writeFloat("imageHeight", 300);
之后就可以加载图片了,但是加载出来的都是图片/sdcard/image/img01.jpg,请问这里应该怎么修改啊?
我不知道这里的_name,和_size.x,_size.y是从哪里传进来的?还望指教一下,不胜感激!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions