如何利用电晕SDK我显示从SD卡或手机内存中的形象?`如何加载SD卡从图像电晕SDK
4
A
回答
0
我使用电晕SDK来开发适用于iOS,但我相信电晕应用程序是沙盒和您无法在沙箱外读取任何内容。以为这可能只适用于iOS应用程序。
6
可以在Android上使用LFS和IO API读取和写入SD卡上的文件。
要访问手机inbuild内存,添加android权限“android.permission.WRITE_EXTERNAL_STORAGE”并将路径设置为“/”。从那里你可以访问存储卡。
实施例:
local lfs = require("lfs")
local path = "/"
local pathType = ""
-- Check to see if path exists
if path and lfs.attributes(path) then
pathType = lfs.attributes(path).mode
end
-- Check if path is a directory
if pathType == "directory" then
for file in lfs.dir(path) do
if "." ~= file and ".." ~= file then
-- Get the file attributes.
local fileAtr = lfs.attributes(path .. "/" .. file)
-- Print path, name and type of file (Directory or file)
print(path,file,fileAtr.mode)
end
end
end
这将打印在终端窗口的路径,文件名和文件类型。 (仅在Mac和Android设备上进行过测试。)
我发现了一种在Android和模拟器上的沙箱外显示图像的方法。 (PC未测试)
例子:
local lfs = require("lfs")
--------------------------- Change this path ---------------------------
local path = "path/to/the/image.jpg" -- Change this path to the path of an image on your computer
------------------------------------------------------------------------
local tmpPath = system.pathForFile("tmp.jpg",system.TemporaryDirectory) -- Destination path to the temporary image
--------------------------- Read ----------------------------
local file, reason = io.open(path, "r") -- Open the image in read mode
local contents
if file then
contents = file:read("*a") -- Read contents
io.close(file) -- Close the file (Important!)
else
print("Invalid path")
return
end
--------------------------- Write ----------------------------
local file = io.open(tmpPath, "w") -- Open the destination path in write mode
if file then
file:write(contents) -- Writes the contents to a file
io.close(file) -- Close the file (Important!)
else
print("Error")
return
end
---------------------- Open and remove -----------------------
local img = display.newImage("tmp.jpg",system.TemporaryDirectory) -- Display the image from the temporary directory
os.remove(tmpPath) -- Removes the image, so that we can load another image.
相关问题
- 1. 电晕图像保存到SD卡
- 2. 从SD卡快速加载图像
- 3. 使用Glide从SD卡加载图像
- 4. 刷卡方向电晕SDK
- 5. 图片加载SD卡从
- 6. 如何从SD卡加载图像到寻呼机适配器?
- 7. 如何从SD卡android加载不同大小的图像?
- 8. 如何从SD卡加载图像到coverview中
- 9. 如何在运行时从SD卡加载ImageButton图像?
- 10. 如何从SD卡上一次加载图像?
- 11. Android +电晕SDK:无法加载Lua
- 12. 如何将从SD卡加载的图像缩放到图像视图?
- 13. 如何利用电晕SDK
- 14. 如何添加SD卡图像到coverflow?
- 15. Android:如何从SD卡上传图像
- 16. 如何从SD卡检索图像
- 17. 如何从SD卡上的CoverFlow图像
- 18. Android:如何:从SD卡显示图像?
- 19. 保存图像在SD卡后毕加索加载图像
- 20. 不能将图像从SD卡加载到网格视图
- 21. 从SD卡共享图像
- 22. 如何旋转使用iPhone的电晕sdk图像
- 23. 电晕sdk:得分
- 24. 电晕SDK,旋转
- 25. 从SD卡加载图像到imageview不起作用
- 26. 从GridView中的SD卡目录加载图像
- 27. GridView从SD卡加载图像时显示白色屏幕
- 28. 从SD卡加载的图像路径错误
- 29. 从AndEngine的SD卡加载图像为雪碧GLES2
- 30. 从SD卡动态加载图像更改相对布局?
我认为üR右..我用Google搜索这个问题,但没有得到任何合适的回答,我感觉堆栈溢出,少电晕开发商!我在5天只有16view ...这里很难得到答案.. thnks您的评论..我的意思是答案.. – vnshetty
不用担心。恐怕Ansca为了让Corona在Android和iOS平台上工作,不得不放弃从沙箱外部读取文件的支持。我不认为科罗娜像Cocos2d那样受欢迎,在这里得到这样的关注。你最好在他们的论坛上提问。 – Krystian