rhcad / vgandroid

A lightweight 2D vector drawing framework for Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

StephenLee9 opened this issue · comments

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

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

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

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

在 2014年11月6日,上午10:31,"StephenLeo" notifications@github.com 写道:

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


Reply to this email directly or view it on GitHub.

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

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

谢谢
张云贵

在 2014年11月6日,上午11:11,"StephenLeo" notifications@github.com 写道:

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


Reply to this email directly or view it on GitHub.

这个可以修改吗?