• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

britzl/defold-screenshot: Screenshot extension for the Defold game engine

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

britzl/defold-screenshot

开源软件地址:

https://github.com/britzl/defold-screenshot

开源编程语言:

C 64.9%

开源软件介绍:

Defold-Screenshot

Screenshot extension for the Defold game engine

Installation

You can use Defold-Screenshot in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/britzl/defold-screenshot/archive/master.zip

Or point to the ZIP file of a specific release.

API

The screenshot API provides four versions of each function:

  • Partial screenshot - synchronous. Not available on HTML5.
  • Fullscreen screenshot - synchronous. Not available on HTML5.
  • Partial screenshot - asynchronous
  • Fullscreen screenshot - asynchronous

The asynchronous versions will capture the screenshot on POST RENDER. The synchronous versions will capture the screenshot immediately. On some mobile devices this may result in a blank capture.

screenshot.png([x, y, w, h, [callback]])

Capture a full screen or partial screenshot as a PNG. Example:

-- fullscreen with callback
screenshot.png(function(self, image, w, h)
	-- do something with image
end)

-- partial with callback
-- 100x200 pixels starting from 0,0 (lower left corner)
screenshot.png(0, 0, 100, 200, function(self, image, w, h)
	-- do something with image
end)

-- fullscreen
local image, w, h = screenshot.png()

-- partial
-- 100x200 pixels starting from 0,0 (lower left corner)
local image, w, h = screenshot.png(0, 0, 100, 200)

screenshot.buffer([x, y, w, h, [callback]])

Capture a full screen or partial screenshot as a Defold buffer.

-- Take screenshot and return it as a Defold buffer
-- Set buffer as texture on a model
local buffer, w, h = screenshot.buffer()
local url = go.get("cube#model", "texture0")
resource.set_texture(url, { type = resource.TEXTURE_TYPE_2D, width = w, height = h, format = resource.TEXTURE_FORMAT_RGBA }, buffer)

screenshot.pixels([x, y, w, h, [callback]])

Capture a full screen or partial screenshot as raw pixels.

-- Take screenshot and return pixels as a Lua string
local pixels, w, h = screenshot.pixels()

Credits

  • fpng for PNG encoding
  • Graphics in example by Kenney



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap