{"id":1496,"date":"2009-11-24T19:45:58","date_gmt":"2009-11-24T10:45:58","guid":{"rendered":"http:\/\/blog.bitmeister.jp\/?p=1496"},"modified":"2010-04-06T22:05:15","modified_gmt":"2010-04-06T13:05:15","slug":"qr%e3%82%b3%e3%83%bc%e3%83%89%e7%94%9f%e6%88%90web%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9qr-bmp","status":"publish","type":"post","link":"https:\/\/blog.bitmeister.jp\/?p=1496","title":{"rendered":"QR\u30b3\u30fc\u30c9\u751f\u6210Web\u30b5\u30fc\u30d3\u30b9QR-BMP"},"content":{"rendered":"<p>\u52d5\u7684\u306b(URL\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u6307\u5b9a\u3067)QR\u30b3\u30fc\u30c9&reg;\u3092\u751f\u6210\u3059\u308bWeb\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002<br \/>\n\u3059\u3067\u306b\u305d\u3046\u3044\u3046\u30b5\u30fc\u30d3\u30b9\u306f\u3044\u304f\u3064\u304b\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30b3\u30e9\u30dc\u3055\u3044\u305f\u307e2009\u306e\u5f53\u793e\u5c55\u793a\u3067\u306e\u4f7f\u7528\u306e\u305f\u3081\u3001\u3088\u305d\u69d8\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u4f7f\u308f\u306a\u3044\u3067\u3059\u3080\u3088\u3046\u306b\u81ea\u524d\u3067\u3064\u304f\u308a\u307e\u3057\u305f\u3002<br \/>\n\u304a\u304b\u3052\u3055\u307e\u3067\u7121\u4e8b\u3001\u5c55\u793a\uff08\u304a\u3088\u3073\u30d5\u30a9\u30ed\u30fc\u30b5\u30a4\u30c8\u306e\u904b\u7528\uff09\u3082\u7d42\u308f\u3063\u305f\u306e\u3067\u3001\u30b5\u30fc\u30d3\u30b9\u306e\u958b\u653e\u304a\u3088\u3073\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u516c\u958b\u3092\u3057\u307e\u3059\u3002<br \/>\n<!--more--><br \/>\n\u4ed6\u306e\u30b5\u30fc\u30d3\u30b9\u3067\u306f\u3001QR\u30b3\u30fc\u30c9\u3092jpg\u3067\u51fa\u3057\u305f\u308aswf\u3067\u51fa\u3057\u305f\u308a\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u79c1\u304c\u4f5c\u3063\u305f\u3082\u306e\u306fbitmap\u3067\u3059\u3002<br \/>\n\uff08\u5358\u7d14\u306a\u767d\u9ed2\u753b\u50cf\u306a\u3089bitmap\u3067\u5341\u5206\u304b\u306a\u3001\u3068\u3044\u3046\u3060\u3051\u306e\u7406\u7531\u3067\u3059\u3002\u6df1\u304f\u8003\u3048\u305f\u308f\u3051\u3067\u306f\u306a\u3044\u3067\u3059\u3002\uff09<\/p>\n<p>\u3054\u5229\u7528\u3044\u305f\u3060\u304f\u969b\u306f\u3001\u305d\u306e\u307e\u307e\u5f53\u793e\u306e\u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u305f\u3060\u3044\u3066\u3082\u3088\u3044\u3067\u3059\u3057\u3001\u4e0b\u8a18\u306e\u624b\u9806\u3067\u304a\u624b\u6301\u3061\u306e\u30b5\u30a4\u30c8\u306b\u5c0e\u5165\u3057\u3066\u3082\u3044\u305f\u3060\u3044\u3066\u3082\u69cb\u3044\u307e\u305b\u3093\u3002<\/p>\n<p>\u5f53\u793e\u30b5\u30a4\u30c8\u3067\u306e\u4f7f\u7528\u65b9\u6cd5\u306f\u6b21\u306e\u30b5\u30a4\u30c8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<br \/>\n<a href=\"http:\/\/labs.bitmeister.jp\/qrmake\/index.html\">QR-BMP QR\u30b3\u30fc\u30c9Bitmap\u751f\u6210\u30b5\u30fc\u30d3\u30b9<\/a><\/p>\n<p style=\"color:red; font-weight:bold\">2010\/4\/6 \u751f\u6210\u3055\u308c\u308b\u30a4\u30e1\u30fc\u30b8\u304c\u8aad\u307f\u53d6\u308a\u306b\u304f\u3044\u5834\u5408\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u4f59\u767d\u3092\u3064\u3051\u3089\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\u8a73\u3057\u304f\u306f\u4e0a\u8a18\u30b5\u30a4\u30c8\u3092\u5fa1\u89a7\u4e0b\u3055\u3044\u3002\u6700\u65b0\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3082\u305d\u3061\u3089\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u81ea\u524d\u3067\u30b5\u30fc\u30d3\u30b9\u3092\u7acb\u3061\u4e0a\u3052\u308b\u969b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u5c0e\u5165\u624b\u9806\u3082\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u4e0b\u8a18\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u6539\u5909\u3001\u518d\u914d\u5e03\u81ea\u7531\u3067\u3059\u3002<\/p>\n<h2>\u5fc5\u8981\u306a\u5916\u90e8\u30d1\u30c3\u30b1\u30fc\u30b8<\/h2>\n<ul>\n<li><a href=\"http:\/\/libpanda.s18.xrea.com\/qrcode.html\">python \u3067 QR \u30b3\u30fc\u30c9\u4f5c\u6210<\/a>\u306b\u3042\u308b<a href=\"http:\/\/libpanda.s18.xrea.com\/qr\/pyqrcode.py\">pyqrcode.py<\/a><\/li>\n<li><a href=\"http:\/\/www.vancouver.wsu.edu\/fac\/langd\/CS_121\/mandelbrot\/bmp.py\">bmp.py<\/a><\/li>\n<\/ul>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<p>pybmp.py<br \/>\n(python 2.4\u3067\u52d5\u4f5c\u78ba\u8a8d)<br \/>\n<code><\/p>\n<p>#!\/usr\/bin\/python<br \/>\n# -*- coding: utf-8 -*-<\/p>\n<p>import cgi<br \/>\nimport cgitb; cgitb.enable()<br \/>\nimport time<\/p>\n<p>def error():<br \/>\n  print \"Content-type: text\/html; charset=UTF-8\"<br \/>\n  print \"Pragma: no-cache\"<br \/>\n  print \"Cache-Control: no-cache\"<br \/>\n  print<br \/>\n  print '''<br \/>\n<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\"><br \/>\n<html lang=\"ja\"><br \/>\n<head><br \/>\n<META HTTP-EQUIV=\"Content-type\" CONTENT=\"text\/html; charset=UTF-8\"><br \/>\n<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"><br \/>\n<META HTTP-EQUIV=\"Cache-Control\" CONTENT=\"no-cache\"><br \/>\n<title>Error<\/title><br \/>\n<\/head><br \/>\n<body><br \/>\nNo Strings for QR!<br \/>\n<\/body><br \/>\n<\/html><br \/>\n'''<\/p>\n<p>qrstr=\"\"<br \/>\nscale=5<\/p>\n<p>import os<br \/>\nimport sys<\/p>\n<p>form = cgi.FieldStorage()<br \/>\nif form.has_key('str'):<br \/>\n  qrstr = form.getfirst('str','')<br \/>\nelse:<br \/>\n  qrstr = os.environ.get('HTTP_REFERER','')<br \/>\n  if qrstr == '':<br \/>\n    error()<br \/>\n    sys.exit()<\/p>\n<p>if form.has_key('scale'):<br \/>\n  scalestr = form.getfirst('scale','')<br \/>\n  scale = int(scalestr)<\/p>\n<p>sys.path.append('ext')<br \/>\nimport pyqrcode<br \/>\nimport tempfile<br \/>\nstdout_bk = sys.stdout<br \/>\nsys.stdout = tempfile.TemporaryFile()<br \/>\nimport bmp<br \/>\nsys.stdout.close()<br \/>\nsys.stdout = stdout_bk<\/p>\n<p>a = pyqrcode.Qrcode()<br \/>\na.path = 'ext\/qrcode_data'<br \/>\ns = a.make_qrcode(qrstr)<br \/>\nx = 0<br \/>\ny = 0<br \/>\ny_max = len(s.split())<br \/>\nx_max = 0<br \/>\nif y_max > 0:<br \/>\n  x_max = len(s.split()[0])<br \/>\nbitmap = bmp.BitMap(x_max*scale,y_max*scale)<br \/>\ny = (y_max - 1) * scale<br \/>\nfor line in s.split():<br \/>\n  for ch in line:<br \/>\n    if ch == '1':<br \/>\n      for sc_x in range(0,scale):<br \/>\n        for sc_y in range(0,scale):<br \/>\n          bitmap.plotPoint(x+sc_x,y+sc_y)<br \/>\n    x = x + scale<br \/>\n  x = 0<br \/>\n  y = y - scale<br \/>\n(fdno,filepath) = tempfile.mkstemp()<br \/>\nf = os.fdopen(fdno,\"r\")<br \/>\nf.close()<br \/>\nif sys.platform == \"win32\":<br \/>\n  import msvcrt<br \/>\n  msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)<br \/>\nbitmap.saveFile(filepath)<br \/>\nprint \"Content-type: image\/bmp\"<br \/>\nprint \"Accept-Ranges: bytes\"<br \/>\nprint \"Content-Length: \"+str(os.stat(filepath)[6])<br \/>\nprint<br \/>\nf = open(filepath,\"rb\")<br \/>\n_bufferSize=1000<br \/>\nwhile True:<br \/>\n  buffer = f.read(_bufferSize)<br \/>\n  sys.stdout.write(buffer)<br \/>\n  if len(buffer) < _bufferSize:\n    break\nf.close()\nos.remove(filepath)\n[\/python]\n<\/code><\/p>\n<h2>\u5c0e\u5165\u624b\u9806<\/h2>\n<p>\u4e0a\u8a18\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9(pybmp.py)\u3092python CGI\u304c\u5b9f\u884c\u53ef\u80fd\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u914d\u7f6e\u3057\u3066\u3001\u3055\u3089\u306b\u305d\u3053\u306bext\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u5fc5\u8981\u306a\u5916\u90e8\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u5b9f\u884c\u6a29\u7b49\u306b\u3064\u3044\u3066\u306f\u3001\u901a\u5e38\u306epython CGI\u3068\u540c\u3058\u3067\u3059\u3002<br \/>\n\u914d\u7f6e\u30a4\u30e1\u30fc\u30b8<\/p>\n<table border=\"0\">\n<tr>\n<td>(base directory)<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\">+<\/td>\n<td align=\"left\">pybmp.py<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\">+<\/td>\n<td align=\"left\">ext<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td align=\"center\">+<\/td>\n<td>bmp.py<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td align=\"center\">+<\/td>\n<td>pyqrcode.py<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td align=\"center\">+<\/td>\n<td>qrcode_data (*)<\/td>\n<\/tr>\n<\/table>\n<p>\n\u3061\u306a\u307f\u306b\u3001bmp.py\u306f\u7f6e\u304f\u3060\u3051\u3067\u4f7f\u3048\u307e\u3059\u304c\u3001pyqrcode.py\u306f\u30ea\u30f3\u30af\u5148\u306b\u66f8\u3044\u3066\u3042\u308b\u3068\u304a\u308a\u3001python\u30b9\u30af\u30ea\u30d7\u30c8\u4ee5\u5916\u306b\u30c7\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb(\u4e0a\u8a18*\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5185\u5bb9\u7269)\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u8a73\u3057\u304f\u306f<a href=\"http:\/\/libpanda.s18.xrea.com\/qrcode.html\">\u3053\u3061\u3089<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u203b<a href=\"http:\/\/www.qrcode.com\/\">QR\u30b3\u30fc\u30c9&reg;\u306f\u3001\u682a\u5f0f\u4f1a\u793e\u30c7\u30f3\u30bd\u30fc\u30a6\u30a7\u30fc\u30d6\u306e\u767b\u9332\u5546\u6a19\u3067\u3059\u3002<\/a><br \/>\n\u203bbmp.py\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u7248\u304c<a href=\"http:\/\/code.google.com\/p\/pybmp\/\">\u3053\u3061\u3089<\/a>\u306b\u3042\u308b\u3088\u3046\u3067\u3059\u3002\u305d\u3061\u3089\u3092\u4f7f\u3048\u3070\u3001\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3089\u305a\u306b\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u305b\u305d\u3046\u3067\u3059\u3002<br \/>\n\u203b\u5f53\u793e\u30b5\u30a4\u30c8\u3067\u904b\u7528\u4e2d\u306e\u3082\u306e\u306f\u3001\u5fc5\u305a\u3057\u3082\u4e0a\u8a18\u30bd\u30fc\u30b9\u305d\u306e\u307e\u307e\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u52d5\u7684\u306b(URL\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u6307\u5b9a\u3067)QR\u30b3\u30fc\u30c9&reg;\u3092\u751f\u6210\u3059\u308bWeb\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002 \u3059\u3067\u306b\u305d\u3046\u3044\u3046\u30b5\u30fc\u30d3\u30b9\u306f\u3044\u304f\u3064\u304b\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30b3\u30e9\u30dc\u3055\u3044\u305f\u307e2009\u306e\u5f53\u793e\u5c55\u793a\u3067\u306e\u4f7f\u7528\u306e\u305f\u3081\u3001\u3088\u305d\u69d8\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u4f7f\u308f\u306a\u3044\u3067 [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[80,46,40],"class_list":["post-1496","post","type-post","status-publish","format-standard","hentry","category-tech","tag-python","tag-46","tag-40"],"_links":{"self":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/1496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1496"}],"version-history":[{"count":11,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/1496\/revisions"}],"predecessor-version":[{"id":1569,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/1496\/revisions\/1569"}],"wp:attachment":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}