ext/rqr/qr_draw_png.cpp in z-rqr-0.2.3 vs ext/rqr/qr_draw_png.cpp in z-rqr-0.2.4
- old
+ new
@@ -1,47 +1,20 @@
#include "qr_draw_png.h"
-//=================================================================================
-// QRDrawPNG::QRDrawPNG
-//=================================================================================
-QRDrawPNG::QRDrawPNG()
-{
-#ifdef USE_PNG
- bit_image = NULL;
-#endif
-}
-
-//=================================================================================
-// QRDrawPNG::~QRDrawPNG
-//=================================================================================
-QRDrawPNG::~QRDrawPNG()
-{
-#ifdef USE_PNG
- int i;
-
- if(bit_image){
- for(i=0; i<this->rsize; i++){
- free(bit_image[i]);
- }
- free(bit_image);
- }
-#endif
-}
-
//=============================================================================
// QRDrawPNG::draw
//=============================================================================
int QRDrawPNG::draw(char *filename, int modulesize, int symbolsize,
unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE], void *opt)
{
#ifdef USE_PNG
setup(filename, modulesize, symbolsize);
- /* ニ値イメージの構築 */
+ /* jlC[W̍\z */
if( this->raster(data) ) return(1);
- /* PNG書き出し */
+ /* PNGo */
if( this->write() ) return(1);
return(0);
#else
return(1);
@@ -54,24 +27,24 @@
int QRDrawPNG::raster(unsigned char data[MAX_MODULESIZE][MAX_MODULESIZE])
{
#ifdef USE_PNG
int bitw = (int)ceil(this->rsize/8) + 1;
- /* 実際にデータを置く領域を確保 */
+ /* ۂɃf[^üm */
bit_image = (unsigned char **)malloc(sizeof(unsigned char *) * this->rsize);
for(int i=0; i<this->rsize; i++){
bit_image[i] = (unsigned char *)malloc(bitw);
memset(bit_image[i], 0, bitw);
}
for(int i=0; i<this->ssize; i++){
- int dp = MARGIN_SIZE*this->msize / 8; //横方向のバイト位置
- int sht =(MARGIN_SIZE*this->msize % 8) ? 3 : 7; //ビットシフト
- unsigned char c = 0; //1バイトの構成を保存
+ int dp = MARGIN_SIZE*this->msize / 8; //̃oCgʒu
+ int sht =(MARGIN_SIZE*this->msize % 8) ? 3 : 7; //rbgVtg
+ unsigned char c = 0; //1oCg̍\ۑ
for(int j=0; j<this->ssize; j++){
- /* 1行分生成 */
+ /* 1s */
for(int k=0; k<this->msize; k++){
c += (data[j][i] << sht);
sht--;
bit_image[(i+MARGIN_SIZE)*this->msize][ dp ] = c;
@@ -81,11 +54,11 @@
c = 0;
dp++;
}
}
}
- /* モジュールサイズ分縦方向に増やす */
+ /* W[TCYcɑ₷ */
for(int k=1; k<this->msize; k++){
memcpy(bit_image[(i+MARGIN_SIZE)*this->msize+k], bit_image[(i+MARGIN_SIZE)*this->msize], bitw);
}
}
@@ -103,11 +76,11 @@
#ifdef USE_PNG
png_structp png_ptr;
png_infop info_ptr;
FILE *stream;
- /* 出力先設定 */
+ /* o͐ݒ */
if(!this->filename){
stream = stdout;
}else{
if( (stream=fopen(this->filename, "wb")) == NULL ) return(1);
}
@@ -116,18 +89,18 @@
info_ptr = png_create_info_struct(png_ptr);
png_init_io(png_ptr, stream);
png_set_filter(png_ptr, 0, PNG_ALL_FILTERS);
png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
- png_set_invert_mono(png_ptr); //白黒反転
+ png_set_invert_mono(png_ptr); //]
- /* IHDRチャンク情報を設定 */
+ /* IHDR`Nݒ */
png_set_IHDR(png_ptr, //png_structp
info_ptr, //png_infop
this->rsize, //width
this->rsize, //height
- 1, //bit_depth(ニ値)
- PNG_COLOR_TYPE_GRAY, //Colorタイプ(ニ値)
+ 1, //bit_depth(jl)
+ PNG_COLOR_TYPE_GRAY, //Color^Cv(jl)
PNG_INTERLACE_NONE, //interlace_method
PNG_COMPRESSION_TYPE_DEFAULT, //compression_method
PNG_FILTER_TYPE_DEFAULT); //filter_method
png_write_info(png_ptr, info_ptr);