Lots of fixes and cleanup
298
Info.plist
Normal file
@ -0,0 +1,298 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>13A603</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>{{project.title}}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{{project.title}}</string>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon-167.png</string>
|
||||
<string>Icon-60@3x.png</string>
|
||||
<string>Icon-60@2x.png</string>
|
||||
<string>Icon-76@2x.png</string>
|
||||
<string>Icon-76.png</string>
|
||||
<string>Icon@2x.png</string>
|
||||
<string>Icon.png</string>
|
||||
<string>Icon-72@2x.png</string>
|
||||
<string>Icon-72.png</string>
|
||||
</array>
|
||||
<key>CFBundleIcons</key>
|
||||
<dict>
|
||||
<key>CFBundlePrimaryIcon</key>
|
||||
<dict>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon-167.png</string>
|
||||
<string>Icon-60@3x.png</string>
|
||||
<string>Icon-60@2x.png</string>
|
||||
<string>Icon-76@2x.png</string>
|
||||
<string>Icon-76.png</string>
|
||||
<string>Icon@2x.png</string>
|
||||
<string>Icon.png</string>
|
||||
<string>Icon-72@2x.png</string>
|
||||
<string>Icon-72.png</string>
|
||||
</array>
|
||||
<key>UIPrerenderedIcon</key>
|
||||
<{{ios.pre_renderered_icons}}/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>{{ios.bundle_identifier}}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>dmengine</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{{project.version}}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>iPhoneOS</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{{project.version}}</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>11B508</string>
|
||||
<key>DTPlatformName</key>
|
||||
<string>iphoneos</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>7.0</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>11B508</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>iphoneos7.0</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0501</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>5A2053</string>
|
||||
<key>UIFileSharingEnabled</key>
|
||||
<{{project.write_log}}/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>6.0.0</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
<string>opengles-2</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array> {{#orientation-support}}
|
||||
<string>UIInterfaceOrientation{{.}}</string>{{/orientation-support}}
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array> {{#orientation-support}}
|
||||
<string>UIInterfaceOrientation{{.}}</string>{{/orientation-support}}
|
||||
</array>
|
||||
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Scan for QR codes</string>
|
||||
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
{{#url-schemes}}<string>{{.}}</string>{{/url-schemes}}
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
{{#application-queries-schemes}}<string>{{.}}</string>{{/application-queries-schemes}}
|
||||
</array>
|
||||
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>facebook.com</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>fbcdn.net</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>akamaihd.net</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
||||
<key>UILaunchImages</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Portrait</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{320, 480}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Landscape</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{320, 480}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-568h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Portrait</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{320, 568}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-568h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Landscape</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{320, 568}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Portrait-667h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Portrait</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{375, 667}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Landscape-667h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Landscape</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{375, 667}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Portrait-736h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Portrait</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{414, 736}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Landscape-736h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Landscape</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{414, 736}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Portrait-1024h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Portrait</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{768, 1024}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Landscape-1024h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Landscape</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{768, 1024}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Portrait-1366h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Portrait</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{1024,1366}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Landscape-1366h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Landscape</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{1024,1366}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Portrait-812h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Portrait</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{375, 812}</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UILaunchImageMinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UILaunchImageName</key>
|
||||
<string>Default-Landscape-812h</string>
|
||||
<key>UILaunchImageOrientation</key>
|
||||
<string>Landscape</string>
|
||||
<key>UILaunchImageSize</key>
|
||||
<string>{375, 812}</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
40
README.md
@ -1,6 +1,44 @@
|
||||
# QRCode
|
||||
|
||||
A simple extension to decode and encode QR codes
|
||||
A small extension to encode and decode QR codes.
|
||||
It relies on [buffers](https://www.defold.com/ref/buffer/).
|
||||
|
||||
For the supported set of QRCodes to decode, see the documentation for [Quirc decoded](https://github.com/dlbeer/quirc)
|
||||
The encoder supports the traditional QR code type.
|
||||
|
||||
# Example app
|
||||
|
||||
Push the Scan button to start scanning for qrcodes. The camera starts running and the the app scans the
|
||||
camera image for the first qrcode. Similarly, push the QRCode button to create a qrcode:
|
||||
<br/>
|
||||
<img src="./screenshots/scan.png" width="350">
|
||||
<img src="./screenshots/create.png" width="350">
|
||||
|
||||
# Lua api:
|
||||
|
||||
## qrcode.scan(buffer, width, height, flip_x) -> string
|
||||
|
||||
Scans an image buffer for any qrcode.
|
||||
|
||||
`buffer` An image buffer where the first stream must be of format `UINT8` * 3, and have the dimensions width*height
|
||||
|
||||
`width` The width of the image, in texels
|
||||
|
||||
`height` The height of the image, in texels
|
||||
|
||||
`flip_x` A boolean flag that tells the decoder to flip the image in X first.
|
||||
|
||||
-> `string` Returns a the text from the qrcode if successful. Returns nil otherwise
|
||||
|
||||
## qrcode.generate(text) -> buffer, size
|
||||
|
||||
Generates a qrcode in the form of a buffer of format: name = 'data', type = `UINT8` * 1, and dimensions `size` * `size`
|
||||
|
||||
`text` The text that needs decoding. The maximum text length is dependent on the [input data](http://www.qrcode.com/en/about/version.html). Kanji is currently not supported specifically, but will be treated as `bytes`
|
||||
|
||||
-> `buffer` An image buffer of dimensions `size` * `size`. The stream name is `data` and the type+count is `UINT8` * 1
|
||||
|
||||
-> `size` The size of one side of the image
|
||||
|
||||
# Credits:
|
||||
|
||||
|
22
game.project
@ -21,4 +21,24 @@ scale = 0.02
|
||||
shared_state = 1
|
||||
|
||||
[library]
|
||||
include_dirs = qrcode
|
||||
include_dirs = qrcode
|
||||
|
||||
[ios]
|
||||
bundle_identifier = com.defold.qrcode
|
||||
infoplist = /Info.plist
|
||||
app_icon_57x57 = /icons/Icon-57.png
|
||||
app_icon_72x72 = /icons/Icon-72.png
|
||||
app_icon_76x76 = /icons/Icon-76.png
|
||||
app_icon_114x114 = /icons/Icon-114.png
|
||||
app_icon_120x120 = /icons/Icon-120.png
|
||||
app_icon_144x144 = /icons/Icon-144.png
|
||||
app_icon_152x152 = /icons/Icon-152.png
|
||||
app_icon_167x167 = /icons/Icon-167.png
|
||||
app_icon_180x180 = /icons/Icon-180.png
|
||||
|
||||
[android]
|
||||
package = com.defold.qrcode
|
||||
|
||||
[osx]
|
||||
bundle_identifier = com.defold.qrcode
|
||||
|
||||
|
BIN
icons/Icon-114.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
icons/Icon-120.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
icons/Icon-144.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
icons/Icon-152.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
icons/Icon-167.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
icons/Icon-180.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
icons/Icon-57.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
icons/Icon-72.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
icons/Icon-76.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
@ -47,51 +47,12 @@ local function update_scan(self)
|
||||
if text ~= nil then
|
||||
msg.post("gui", "set_text", {text=text})
|
||||
end_scan(self)
|
||||
self.mode = "IDLE"
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function rescale_texture_old(src_buf, src_size, dst_buf, dst_size)
|
||||
local src = buffer.get_stream(src_buf, hash("rgb"))
|
||||
local dst = buffer.get_stream(dst_buf, hash("rgb"))
|
||||
print("src", src_size, src_size, src_size*src_size*3)
|
||||
print("dst", dst_size, dst_size, dst_size*dst_size*3)
|
||||
for dy=0,dst_size-1 do
|
||||
local v = dy / dst_size
|
||||
for dx=0,dst_size-1 do
|
||||
local u = dx / dst_size
|
||||
local dst_index = (dy * dst_size + dx) * 3 + 1
|
||||
local src_index = (math.floor(v * src_size) * src_size + math.floor(u * src_size)) * 3 + 1
|
||||
print(dx, dy, dst_index, src_index)
|
||||
dst[dst_index + 0] = src[src_index + 0]
|
||||
dst[dst_index + 1] = src[src_index + 1]
|
||||
dst[dst_index + 2] = src[src_index + 2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function rescale_texture(src_buf, src_size, dst_buf, dst_size)
|
||||
local src = buffer.get_stream(src_buf, hash("rgb"))
|
||||
local dst = buffer.get_stream(dst_buf, hash("rgb"))
|
||||
print("src", src_size, src_size, src_size*src_size*3)
|
||||
print("dst", dst_size, dst_size, dst_size*dst_size*3)
|
||||
for dy=0,dst_size-1 do
|
||||
local v = dy / dst_size
|
||||
for dx=0,dst_size-1 do
|
||||
local u = dx / dst_size
|
||||
local dst_index = (dy * dst_size + dx) * 3 + 1
|
||||
local src_index = (math.floor(v * src_size) * src_size + math.floor(u * src_size)) * 3 + 1
|
||||
print(dx, dy, dst_index, src_index)
|
||||
dst[dst_index + 0] = src[src_index + 0]
|
||||
dst[dst_index + 1] = src[src_index + 1]
|
||||
dst[dst_index + 2] = src[src_index + 2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function generate_qrcode(self, text)
|
||||
local qrcode, qrsize = qrcode.generate(text)
|
||||
|
||||
@ -128,7 +89,6 @@ function final(self)
|
||||
end
|
||||
|
||||
function update(self, dt)
|
||||
|
||||
if self.mode == "SCAN" then
|
||||
update_scan(self)
|
||||
end
|
||||
|
@ -1,29 +0,0 @@
|
||||
function init(self)
|
||||
-- Add initialization code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function final(self)
|
||||
-- Add finalization code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function update(self, dt)
|
||||
-- Add update code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function on_message(self, message_id, message, sender)
|
||||
-- Add message-handling code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
-- Add input-handling code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function on_reload(self)
|
||||
-- Add reload-handling code here
|
||||
-- Remove this function if not needed
|
||||
end
|
@ -16,9 +16,6 @@
|
||||
#define JC_QRENCODE_IMPLEMENTATION
|
||||
#include "jc_qrencode.h"
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
// GENERATE
|
||||
// https://github.com/nayuki/QR-Code-generator
|
||||
|
||||
@ -37,7 +34,7 @@ static int Scan(lua_State* L)
|
||||
dmScript::LuaHBuffer* buffer = dmScript::CheckBuffer(L, 1);
|
||||
int width = luaL_checkint(L, 2);
|
||||
int height = luaL_checkint(L, 3);
|
||||
int flip = luaL_checkint(L, 4);
|
||||
int flip_x = luaL_checkint(L, 4);
|
||||
|
||||
struct quirc* qr;
|
||||
|
||||
@ -74,7 +71,7 @@ static int Scan(lua_State* L)
|
||||
value = 1.0f;
|
||||
}
|
||||
|
||||
if( flip == 0 )
|
||||
if( flip_x == 0 )
|
||||
image[y * width + x] = (uint8_t)(value * 255.0f);
|
||||
else
|
||||
image[y * width + (width - x - 1)] = (uint8_t)(value * 255.0f);
|
||||
@ -113,36 +110,6 @@ static int Scan(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int save_image(JCQRCode* qr, const char* path)
|
||||
{
|
||||
int32_t size = qr->size;
|
||||
|
||||
int32_t border = 0;
|
||||
int32_t scale = 1;
|
||||
int32_t newsize = scale*(size + 2 * border);
|
||||
uint8_t* large = (uint8_t*)malloc( newsize * newsize );
|
||||
|
||||
memset(large, 255, newsize*newsize);
|
||||
|
||||
for( int y = 0; y < size*scale; ++y )
|
||||
{
|
||||
for( int x = 0; x < size*scale; ++x )
|
||||
{
|
||||
uint8_t module = qr->data[(y/scale)*256 + (x/scale)];
|
||||
large[(y + scale*border) * newsize + x + scale*border] = module;
|
||||
}
|
||||
}
|
||||
|
||||
int result = stbi_write_png(path, newsize, newsize, 1, large, newsize);
|
||||
free(large);
|
||||
|
||||
if(result)
|
||||
printf("Wrote to %s\n", path);
|
||||
else
|
||||
printf("Failed to write to %s\n", path);
|
||||
return result;
|
||||
}
|
||||
|
||||
static dmBuffer::HBuffer GenerateImage(JCQRCode* qr, uint32_t* outsize)
|
||||
{
|
||||
int32_t size = qr->size;
|
||||
@ -171,7 +138,8 @@ static dmBuffer::HBuffer GenerateImage(JCQRCode* qr, uint32_t* outsize)
|
||||
{
|
||||
for( int x = 0; x < size*scale; ++x )
|
||||
{
|
||||
uint8_t module = qr->data[(y/scale)*256 + (x/scale)];
|
||||
int flip_y = size*scale - y - 1; // flip it so we can easily pass it as a texture later on
|
||||
uint8_t module = qr->data[(flip_y/scale)*256 + (x/scale)];
|
||||
data[(y + scale*border) * newsize + x + scale*border] = module;
|
||||
}
|
||||
}
|
||||
|
BIN
screenshots/create.png
Normal file
After Width: | Height: | Size: 227 KiB |
BIN
screenshots/scan.png
Normal file
After Width: | Height: | Size: 1.0 MiB |