rqr 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- //---(1)ここから-------------------------
2
- //// QR_Encode.h : CQR_Encode クラス宣言およびインターフェイス定義
1
+ //---(1)��������-------------------------
2
+ //// QR_Encode.h : CQR_Encode �N���X�錾����уC���^�[�t�F�C�X��`
3
3
  //// Date 2006/05/17 Ver. 1.12 [Class Ver.1.22] Psytec Inc.
4
4
  //
5
5
  //#if !defined(AFX_QR_ENCODE_H__AC886DF7_C0AE_4C9F_AC7A_FCDA8CB1DD37__INCLUDED_)
@@ -8,111 +8,111 @@
8
8
  //#if _MSC_VER > 1000
9
9
  //#pragma once
10
10
  //#endif // _MSC_VER > 1000
11
- //---(1)ここまでをコメントアウト-----------
11
+ //---(1)�����܂ł��R�����g�A�E�g-----------
12
12
 
13
- //---(2)ここから-----------
13
+ //---(2)��������-----------
14
14
  #ifndef __QR_ENCODER__
15
15
  #define __QR_ENCODER__
16
16
  #include "win2ansi.h"
17
- //---(2)ここまでを追加-----------
17
+ //---(2)�����܂ł�lj�-----------
18
18
 
19
19
  /////////////////////////////////////////////////////////////////////////////
20
- // 定数
20
+ // �萔
21
21
 
22
- // 誤り訂正レベル
22
+ // ���������x��
23
23
  #define QR_LEVEL_L 0
24
24
  #define QR_LEVEL_M 1
25
25
  #define QR_LEVEL_Q 2
26
26
  #define QR_LEVEL_H 3
27
27
 
28
- // データモード
28
+ // �f�[�^���[�h
29
29
  #define QR_MODE_NUMERAL 0
30
30
  #define QR_MODE_ALPHABET 1
31
31
  #define QR_MODE_8BIT 2
32
32
  #define QR_MODE_KANJI 3
33
33
 
34
- // バージョン(型番)グループ
35
- #define QR_VRESION_S 0 // 1 9
36
- #define QR_VRESION_M 1 // 10 26
37
- #define QR_VRESION_L 2 // 27 40
34
+ // �o�[�W����(�^��)�O���[�v
35
+ #define QR_VRESION_S 0 // 1 �` 9
36
+ #define QR_VRESION_M 1 // 10 �` 26
37
+ #define QR_VRESION_L 2 // 27 �` 40
38
38
 
39
- #define MAX_ALLCODEWORD 3706 // 総コードワード数最大値
40
- #define MAX_DATACODEWORD 2956 // データコードワード最大値(バージョン40-L)
41
- #define MAX_CODEBLOCK 153 // ブロックデータコードワード数最大値(RSコードワードを含む)
42
- #define MAX_MODULESIZE 177 // 一辺モジュール数最大値
39
+ #define MAX_ALLCODEWORD 3706 // ���R�[�h���[�h���ő�l
40
+ #define MAX_DATACODEWORD 2956 // �f�[�^�R�[�h���[�h�ő�l(�o�[�W����40-L)
41
+ #define MAX_CODEBLOCK 153 // �u���b�N�f�[�^�R�[�h���[�h���ő�l(�q�r�R�[�h���[�h���܂�)
42
+ #define MAX_MODULESIZE 177 // ��Ӄ��W���[�����ő�l
43
43
 
44
- // ビットマップ描画時マージン
44
+ // �r�b�g�}�b�v�`�掞�}�[�W��
45
45
  #define QR_MARGIN 4
46
46
 
47
47
 
48
48
  /////////////////////////////////////////////////////////////////////////////
49
49
  typedef struct tagRS_BLOCKINFO
50
50
  {
51
- int ncRSBlock; // RSブロック数
52
- int ncAllCodeWord; // ブロック内コードワード数
53
- int ncDataCodeWord; // データコードワード数(コードワード数 - RSコードワード数)
51
+ int ncRSBlock; // �q�r�u���b�N��
52
+ int ncAllCodeWord; // �u���b�N���R�[�h���[�h��
53
+ int ncDataCodeWord; // �f�[�^�R�[�h���[�h��(�R�[�h���[�h�� - �q�r�R�[�h���[�h��)
54
54
 
55
55
  } RS_BLOCKINFO, *LPRS_BLOCKINFO;
56
56
 
57
57
 
58
58
  /////////////////////////////////////////////////////////////////////////////
59
- // QRコードバージョン(型番)関連情報
59
+ // QR�R�[�h�o�[�W����(�^��)�֘A���
60
60
 
61
61
  typedef struct tagQR_VERSIONINFO
62
62
  {
63
- int nVersionNo; // バージョン(型番)番号(140)
64
- int ncAllCodeWord; // 総コードワード数
63
+ int nVersionNo; // �o�[�W����(�^��)�ԍ�(1�`40)
64
+ int ncAllCodeWord; // ���R�[�h���[�h��
65
65
 
66
- // 以下配列添字は誤り訂正率(0 = L, 1 = M, 2 = Q, 3 = H)
67
- int ncDataCodeWord[4]; // データコードワード数(総コードワード数 - RSコードワード数)
66
+ // �ȉ��z��Y���͌�������(0 = L, 1 = M, 2 = Q, 3 = H)
67
+ int ncDataCodeWord[4]; // �f�[�^�R�[�h���[�h��(���R�[�h���[�h�� - �q�r�R�[�h���[�h��)
68
68
 
69
- int ncAlignPoint; // アライメントパターン座標数
70
- int nAlignPoint[6]; // アライメントパターン中心座標
69
+ int ncAlignPoint; // �A���C�����g�p�^�[�����W��
70
+ int nAlignPoint[6]; // �A���C�����g�p�^�[�����S���W
71
71
 
72
- RS_BLOCKINFO RS_BlockInfo1[4]; // RSブロック情報(1)
73
- RS_BLOCKINFO RS_BlockInfo2[4]; // RSブロック情報(2)
72
+ RS_BLOCKINFO RS_BlockInfo1[4]; // �q�r�u���b�N���(1)
73
+ RS_BLOCKINFO RS_BlockInfo2[4]; // �q�r�u���b�N���(2)
74
74
 
75
75
  } QR_VERSIONINFO, *LPQR_VERSIONINFO;
76
76
 
77
77
 
78
78
  /////////////////////////////////////////////////////////////////////////////
79
- // CQR_Encode クラス
79
+ // CQR_Encode �N���X
80
80
 
81
81
  class CQR_Encode
82
82
  {
83
- // 構築/消滅
83
+ // �\�z/����
84
84
  public:
85
85
  CQR_Encode();
86
86
  ~CQR_Encode();
87
87
 
88
88
  public:
89
- int m_nLevel; // 誤り訂正レベル
90
- int m_nVersion; // バージョン(型番)
91
- BOOL m_bAutoExtent; // バージョン(型番)自動拡張指定フラグ
92
- int m_nMaskingNo; // マスキングパターン番号
89
+ int m_nLevel; // ���������x��
90
+ int m_nVersion; // �o�[�W����(�^��)
91
+ BOOL m_bAutoExtent; // �o�[�W����(�^��)�����g���w��t���O
92
+ int m_nMaskingNo; // �}�X�L���O�p�^�[���ԍ�
93
93
 
94
94
  public:
95
95
  int m_nSymbleSize;
96
96
  BYTE m_byModuleData[MAX_MODULESIZE][MAX_MODULESIZE]; // [x][y]
97
- // bit5:機能モジュール(マスキング対象外)フラグ
98
- // bit4:機能モジュール描画データ
99
- // bit1:エンコードデータ
100
- // bit0:マスク後エンコード描画データ
101
- // 20hとの論理和により機能モジュール判定、11hとの論理和により描画(最終的にはBOOL値化)
97
+ // bit5:�@�\���W���[���i�}�X�L���O�ΏۊO�j�t���O
98
+ // bit4:�@�\���W���[���`��f�[�^
99
+ // bit1:�G���R�[�h�f�[�^
100
+ // bit0:�}�X�N��G���R�[�h�`��f�[�^
101
+ // 20h�Ƃ̘_���a�ɂ��@�\���W���[������A11h�Ƃ̘_���a�ɂ��`��i�ŏI�I�ɂ�BOOL�l���j
102
102
 
103
103
  private:
104
- int m_ncDataCodeWordBit; // データコードワードビット長
105
- BYTE m_byDataCodeWord[MAX_DATACODEWORD]; // 入力データエンコードエリア
104
+ int m_ncDataCodeWordBit; // �f�[�^�R�[�h���[�h�r�b�g��
105
+ BYTE m_byDataCodeWord[MAX_DATACODEWORD]; // ���̓f�[�^�G���R�[�h�G���A
106
106
 
107
107
  int m_ncDataBlock;
108
108
  BYTE m_byBlockMode[MAX_DATACODEWORD];
109
109
  int m_nBlockLength[MAX_DATACODEWORD];
110
110
 
111
- int m_ncAllCodeWord; // 総コードワード数(RS誤り訂正データを含む)
112
- BYTE m_byAllCodeWord[MAX_ALLCODEWORD]; // 総コードワード算出エリア
113
- BYTE m_byRSWork[MAX_CODEBLOCK]; // RSコードワード算出ワーク
111
+ int m_ncAllCodeWord; // ���R�[�h���[�h��(�q�r�������f�[�^���܂�)
112
+ BYTE m_byAllCodeWord[MAX_ALLCODEWORD]; // ���R�[�h���[�h�Z�o�G���A
113
+ BYTE m_byRSWork[MAX_CODEBLOCK]; // �q�r�R�[�h���[�h�Z�o���[�N
114
114
 
115
- // データエンコード関連ファンクション
115
+ // �f�[�^�G���R�[�h�֘A�t�@���N�V����
116
116
  public:
117
117
  BOOL EncodeData(int nLevel, int nVersion, BOOL bAutoExtent, int nMaskingNo, LPCSTR lpsSource, int ncSource = 0);
118
118
 
@@ -133,7 +133,7 @@ private:
133
133
 
134
134
  void GetRSCodeWord(LPBYTE lpbyRSWork, int ncDataCodeWord, int ncRSCodeWord);
135
135
 
136
- // モジュール配置関連ファンクション
136
+ // ���W���[���z�u�֘A�t�@���N�V����
137
137
  private:
138
138
  void FormatModule();
139
139
 
@@ -13,7 +13,14 @@ require 'mkmf'
13
13
  require 'rbconfig'
14
14
  $libs = append_library($libs, "supc++")
15
15
 
16
- DARWIN_PORT_DIR = '/sw'
16
+ FINK_DIR = '/sw'
17
+ MACPORT_DIR = '/opt/local'
18
+
19
+ if File.exists?(FINK_DIR)
20
+ DARWIN_PORT_DIR = FINK_DIR
21
+ else
22
+ DARWIN_PORT_DIR = MACPORT_DIR
23
+ end
17
24
 
18
25
  if RUBY_PLATFORM =~ /darwin/
19
26
  dir_config('jpeg', DARWIN_PORT_DIR)
@@ -1,16 +1,22 @@
1
1
  #ifndef _QR_DRAW_
2
2
  #define _QR_DRAW_
3
3
 
4
- #define MARGIN_SIZE 4 /* マージンサイズ */
5
- #define MAX_MODULESIZE 177 /* データバイト列の領域サイズ */
4
+ #define MARGIN_SIZE 4 /* �}�[�W���T�C�Y */
5
+ #define MAX_MODULESIZE 177 /* �f�[�^�o�C�g��̗̈�T�C�Y */
6
6
 
7
7
  //=============================================================================
8
- // QRDraw クラス
8
+ // QRDraw �N���X
9
9
  //=============================================================================
10
10
  class QRDraw
11
11
  {
12
12
  public:
13
- virtual ~QRDraw(){}
13
+ QRDraw(){
14
+ this->bit_image=NULL;
15
+ }
16
+
17
+ virtual ~QRDraw(){
18
+ this->close();
19
+ }
14
20
 
15
21
  void setup(char *filename, int modulesize, int symbolsize){
16
22
  this->msize = modulesize;
@@ -20,15 +26,23 @@ class QRDraw
20
26
  }
21
27
 
22
28
  protected:
23
- unsigned char **bit_image; //ピクセルイメージを格納する
24
- int msize; // 1ドットを表現するピクセル数(=modulesize)
25
- int rsize; // マージンを含めた実際のイメージの一辺
26
- int ssize; // シンボルサイズ(マージンを含めない、ドットの個数)
27
- char *filename; // 保存するファイル名
29
+ unsigned char **bit_image; //�s�N�Z���C���[�W���i�[����
30
+ int msize; // 1�h�b�g��\������s�N�Z����(=modulesize)
31
+ int rsize; // �}�[�W�����܂߂����ۂ̃C���[�W�̈��
32
+ int ssize; // �V���{���T�C�Y(�}�[�W�����܂߂Ȃ��A�h�b�g�̌�)
33
+ char *filename; // �ۑ�����t�@�C����
28
34
 
29
35
  public:
30
36
  virtual int draw(char *filename, int modulesize, int symbolsize,
31
37
  unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE], void *opt) = 0;
38
+ void close(){
39
+ int i;
40
+ if(this->bit_image){
41
+ for(i=0; i<this->rsize; i++) free(this->bit_image[i]);
42
+ free(this->bit_image);
43
+ }
44
+ this->bit_image=NULL;
45
+ }
32
46
  };
33
47
 
34
48
  #endif
@@ -1,32 +1,5 @@
1
1
  #include "qr_draw_jpeg.h"
2
2
 
3
- //=================================================================================
4
- // QRDrawJPEG::QRDrawJPEG
5
- //=================================================================================
6
- QRDrawJPEG::QRDrawJPEG()
7
- {
8
- #ifdef USE_JPG
9
- bit_image = NULL;
10
- #endif
11
- }
12
-
13
- //=================================================================================
14
- // QRDrawJPEG::~QRDrawJPEG
15
- //=================================================================================
16
- QRDrawJPEG::~QRDrawJPEG()
17
- {
18
- #ifdef USE_JPG
19
- int i;
20
-
21
- if(bit_image){
22
- for(i=0; i<this->rsize; i++){
23
- free(bit_image[i]);
24
- }
25
- free(bit_image);
26
- }
27
- #endif
28
- }
29
-
30
3
  //=============================================================================
31
4
  // QRDrawJPEG::draw
32
5
  //=============================================================================
@@ -36,10 +9,10 @@ int QRDrawJPEG::draw(char *filename, int modulesize, int symbolsize,
36
9
  #ifdef USE_JPG
37
10
  setup(filename, modulesize, symbolsize);
38
11
 
39
- /* グレースケールイメージの構築 */
12
+ /* �O���[�X�P�[���C���[�W�̍\�z */
40
13
  if( this->raster(data) ) return(1);
41
14
 
42
- /* JPEG書き出し */
15
+ /* JPEG�����o�� */
43
16
  if( this->write() ) return(1);
44
17
 
45
18
  return(0);
@@ -56,7 +29,7 @@ int QRDrawJPEG::raster(unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE])
56
29
  #ifdef USE_JPG
57
30
  int i, j, k;
58
31
 
59
- /* 実際にデータを置く領域を確保 */
32
+ /* ���ۂɃf�[�^��u���̈���m�� */
60
33
  bit_image = (unsigned char **)malloc(sizeof(unsigned char *) * this->rsize);
61
34
  for(i=0; i<this->rsize; i++){
62
35
  bit_image[i] = (unsigned char *)malloc(this->rsize);
@@ -65,12 +38,12 @@ int QRDrawJPEG::raster(unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE])
65
38
 
66
39
  for(i=0; i<this->ssize; i++){
67
40
  for(j=0; j<this->ssize; j++){
68
- /* 1行分生成 */
41
+ /* 1�s������ */
69
42
  for(k=0; k<this->msize; k++){
70
43
  bit_image[(i+MARGIN_SIZE)*this->msize][ (j+MARGIN_SIZE)*this->msize + k ] = data[j][i] ? 0 : 255;
71
44
  }
72
45
  }
73
- /* モジュールサイズ分縦方向に増やす */
46
+ /* ���W���[���T�C�Y���c�����ɑ��₷ */
74
47
  for(k=1; k<this->msize; k++){
75
48
  memcpy(bit_image[(i+MARGIN_SIZE)*this->msize+k], bit_image[(i+MARGIN_SIZE)*this->msize], this->rsize);
76
49
  }
@@ -94,7 +67,7 @@ int QRDrawJPEG::write()
94
67
  FILE *stream;
95
68
  int i;
96
69
 
97
- /* 出力先設定 */
70
+ /* �o�͐�ݒ� */
98
71
  if(!this->filename){
99
72
  stream = stdout;
100
73
  }else{
@@ -11,7 +11,7 @@
11
11
  #endif
12
12
 
13
13
  //=============================================================================
14
- // QRDrawJPEG クラス
14
+ // QRDrawJPEG �N���X
15
15
  //=============================================================================
16
16
  class QRDrawJPEG : public QRDraw
17
17
  {
@@ -20,8 +20,8 @@ class QRDrawJPEG : public QRDraw
20
20
  int write();
21
21
 
22
22
  public:
23
- QRDrawJPEG();
24
- ~QRDrawJPEG();
23
+ QRDrawJPEG(){}
24
+ ~QRDrawJPEG(){}
25
25
  int draw(char *filename, int modulesize, int symbolsize,
26
26
  unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE], void *opt);
27
27
  };
@@ -1,32 +1,5 @@
1
1
  #include "qr_draw_png.h"
2
2
 
3
- //=================================================================================
4
- // QRDrawPNG::QRDrawPNG
5
- //=================================================================================
6
- QRDrawPNG::QRDrawPNG()
7
- {
8
- #ifdef USE_PNG
9
- bit_image = NULL;
10
- #endif
11
- }
12
-
13
- //=================================================================================
14
- // QRDrawPNG::~QRDrawPNG
15
- //=================================================================================
16
- QRDrawPNG::~QRDrawPNG()
17
- {
18
- #ifdef USE_PNG
19
- int i;
20
-
21
- if(bit_image){
22
- for(i=0; i<this->rsize; i++){
23
- free(bit_image[i]);
24
- }
25
- free(bit_image);
26
- }
27
- #endif
28
- }
29
-
30
3
  //=============================================================================
31
4
  // QRDrawPNG::draw
32
5
  //=============================================================================
@@ -36,10 +9,10 @@ int QRDrawPNG::draw(char *filename, int modulesize, int symbolsize,
36
9
  #ifdef USE_PNG
37
10
  setup(filename, modulesize, symbolsize);
38
11
 
39
- /* ニ値イメージの構築 */
12
+ /* �j�l�C���[�W�̍\�z */
40
13
  if( this->raster(data) ) return(1);
41
14
 
42
- /* PNG書き出し */
15
+ /* PNG�����o�� */
43
16
  if( this->write() ) return(1);
44
17
 
45
18
  return(0);
@@ -56,7 +29,7 @@ int QRDrawPNG::raster(unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE])
56
29
  #ifdef USE_PNG
57
30
  int bitw = (int)ceil(this->rsize/8) + 1;
58
31
 
59
- /* 実際にデータを置く領域を確保 */
32
+ /* ���ۂɃf�[�^��u���̈���m�� */
60
33
  bit_image = (unsigned char **)malloc(sizeof(unsigned char *) * this->rsize);
61
34
  for(int i=0; i<this->rsize; i++){
62
35
  bit_image[i] = (unsigned char *)malloc(bitw);
@@ -64,12 +37,12 @@ int QRDrawPNG::raster(unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE])
64
37
  }
65
38
 
66
39
  for(int i=0; i<this->ssize; i++){
67
- int dp = MARGIN_SIZE*this->msize / 8; //横方向のバイト位置
68
- int sht =(MARGIN_SIZE*this->msize % 8) ? 3 : 7; //ビットシフト
69
- unsigned char c = 0; //1バイトの構成を保存
40
+ int dp = MARGIN_SIZE*this->msize / 8; //�������̃o�C�g�ʒu
41
+ int sht =(MARGIN_SIZE*this->msize % 8) ? 3 : 7; //�r�b�g�V�t�g
42
+ unsigned char c = 0; //1�o�C�g�̍\����ۑ�
70
43
 
71
44
  for(int j=0; j<this->ssize; j++){
72
- /* 1行分生成 */
45
+ /* 1�s������ */
73
46
  for(int k=0; k<this->msize; k++){
74
47
  c += (data[j][i] << sht);
75
48
  sht--;
@@ -83,7 +56,7 @@ int QRDrawPNG::raster(unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE])
83
56
  }
84
57
  }
85
58
  }
86
- /* モジュールサイズ分縦方向に増やす */
59
+ /* ���W���[���T�C�Y���c�����ɑ��₷ */
87
60
  for(int k=1; k<this->msize; k++){
88
61
  memcpy(bit_image[(i+MARGIN_SIZE)*this->msize+k], bit_image[(i+MARGIN_SIZE)*this->msize], bitw);
89
62
  }
@@ -105,7 +78,7 @@ int QRDrawPNG::write()
105
78
  png_infop info_ptr;
106
79
  FILE *stream;
107
80
 
108
- /* 出力先設定 */
81
+ /* �o�͐�ݒ� */
109
82
  if(!this->filename){
110
83
  stream = stdout;
111
84
  }else{
@@ -118,15 +91,15 @@ int QRDrawPNG::write()
118
91
  png_init_io(png_ptr, stream);
119
92
  png_set_filter(png_ptr, 0, PNG_ALL_FILTERS);
120
93
  png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
121
- png_set_invert_mono(png_ptr); //白黒反転
94
+ png_set_invert_mono(png_ptr); //�������]
122
95
 
123
- /* IHDRチャンク情報を設定 */
96
+ /* IHDR�`�����N����ݒ� */
124
97
  png_set_IHDR(png_ptr, //png_structp
125
98
  info_ptr, //png_infop
126
99
  this->rsize, //width
127
100
  this->rsize, //height
128
- 1, //bit_depth(ニ値)
129
- PNG_COLOR_TYPE_GRAY, //Colorタイプ(ニ値)
101
+ 1, //bit_depth(�j�l)
102
+ PNG_COLOR_TYPE_GRAY, //Color�^�C�v(�j�l)
130
103
  PNG_INTERLACE_NONE, //interlace_method
131
104
  PNG_COMPRESSION_TYPE_DEFAULT, //compression_method
132
105
  PNG_FILTER_TYPE_DEFAULT); //filter_method
@@ -10,7 +10,7 @@
10
10
  #endif
11
11
 
12
12
  //=============================================================================
13
- // QRDrawPNG クラス
13
+ // QRDrawPNG �N���X
14
14
  //=============================================================================
15
15
  class QRDrawPNG : public QRDraw
16
16
  {
@@ -19,8 +19,8 @@ class QRDrawPNG : public QRDraw
19
19
  int write();
20
20
 
21
21
  public:
22
- QRDrawPNG();
23
- ~QRDrawPNG();
22
+ QRDrawPNG(){}
23
+ ~QRDrawPNG(){}
24
24
  int draw(char *filename, int modulesize, int symbolsize,
25
25
  unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE], void *opt);
26
26
  };