Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
StephenLee9 opened this issue Nov 5, 2014 · 6 comments
Open

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

StephenLee9 opened this issue Nov 5, 2014 · 6 comments

Comments

@StephenLee9
Copy link

文件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是从哪里传进来的?还望指教一下,不胜感激!

@rhcad
Copy link
Owner

rhcad commented Nov 5, 2014

不是Bug,ViewHelper有相应的设置图像路径的函数setImagePath。

@StephenLee9
Copy link
Author

知道了,但是setImagePath貌似只能设置一个路径,如果我要自动加载的图片在不同的目录应该怎么解决呢?

@rhcad
Copy link
Owner

rhcad commented Nov 6, 2014

可以先放在一个目录再插入图片。

在 2014年11月6日,上午10:31,"StephenLeo" [email protected] 写道:

知道了,但是setImagePath貌似只能设置一个路径,如果我要自动加载的图片在不同的目录应该怎么解决呢?


Reply to this email directly or view it on GitHub.

@StephenLee9
Copy link
Author

好吧,这样倒是可以。如果在insertImageFromFile中传入图片的全路径,貌似路径+名称超过63个字符就加载不出来了,这是为什么呢?

@rhcad
Copy link
Owner

rhcad commented Nov 6, 2014

无路径的内部名称不超过63的

谢谢
张云贵

在 2014年11月6日,上午11:11,"StephenLeo" [email protected] 写道:

好吧,这样倒是可以。如果在insertImageFromFile中传入图片的全路径,貌似路径+名称超过63个字符就加载不出来了,这是为什么呢?


Reply to this email directly or view it on GitHub.

@StephenLee9
Copy link
Author

这个可以修改吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants