Skip to content

Commit

Permalink
QRCode generate fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Mar 10, 2017
1 parent e7cf516 commit 6fe3fb9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 84 deletions.
8 changes: 0 additions & 8 deletions src/PeratX/SFQRCode/QRCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public function encodeMask(QRInput $input, $mask){
$frame = QRSpec::newFrame($version);

$filler = new FrameFiller($width, $frame);
if(is_null($filler)){
return NULL;
}

// inteleaved data and ecc codes
for($i = 0; $i < $raw->dataLength + $raw->eccLength; $i++){
Expand Down Expand Up @@ -76,10 +73,6 @@ public function encodeMask(QRInput $input, $mask){
$masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
}

if($masked == NULL){
return NULL;
}

$this->version = $version;
$this->width = $width;
$this->data = $masked;
Expand Down Expand Up @@ -116,7 +109,6 @@ public function encodeString($string, $version, $level, $hint, $casesensitive){
}

$input = new QRInput($version, $level);
if($input == NULL) return NULL;

$ret = QRSplit::splitStringToQRInput($string, $input, $hint, $casesensitive);
if($ret < 0){
Expand Down
3 changes: 1 addition & 2 deletions src/PeratX/SFQRCode/QREncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class QREncode{

public $caseSensitive = true;
public $eightBit = false;
public $eightBit = true;

public $version = 0;
public $size = 3;
Expand Down Expand Up @@ -87,7 +87,6 @@ public function encode($intext){
$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->caseSensitive);
}

var_dump($code->data);
return QRTools::binarize($code->data);
}

Expand Down
75 changes: 1 addition & 74 deletions src/PeratX/SFQRCode/QRSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,79 +435,6 @@ public static function createFrame($version){
return $frame;
}


public static function debug($frame, $binary_mode = false){
if($binary_mode){

foreach($frame as &$frameLine){
$frameLine = join('<span class="m">&nbsp;&nbsp;</span>', explode('0', $frameLine));
$frameLine = join('&#9608;&#9608;', explode('1', $frameLine));
}

?>
<style>
.m {
background-color: white;
}
</style>
<?php
echo '<pre><tt><br/ ><br/ ><br/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
echo join("<br/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $frame);
echo '</tt></pre><br/ ><br/ ><br/ ><br/ ><br/ ><br/ >';

}else{

foreach($frame as &$frameLine){
$frameLine = join('<span class="m">&nbsp;</span>', explode("\xc0", $frameLine));
$frameLine = join('<span class="m">&#9618;</span>', explode("\xc1", $frameLine));
$frameLine = join('<span class="p">&nbsp;</span>', explode("\xa0", $frameLine));
$frameLine = join('<span class="p">&#9618;</span>', explode("\xa1", $frameLine));
$frameLine = join('<span class="s">&#9671;</span>', explode("\x84", $frameLine)); //format 0
$frameLine = join('<span class="s">&#9670;</span>', explode("\x85", $frameLine)); //format 1
$frameLine = join('<span class="x">&#9762;</span>', explode("\x81", $frameLine)); //special bit
$frameLine = join('<span class="c">&nbsp;</span>', explode("\x90", $frameLine)); //clock 0
$frameLine = join('<span class="c">&#9719;</span>', explode("\x91", $frameLine)); //clock 1
$frameLine = join('<span class="f">&nbsp;</span>', explode("\x88", $frameLine)); //version
$frameLine = join('<span class="f">&#9618;</span>', explode("\x89", $frameLine)); //version
$frameLine = join('&#9830;', explode("\x01", $frameLine));
$frameLine = join('&#8901;', explode("\0", $frameLine));
}

?>
<style>
.p {
background-color: yellow;
}

.m {
background-color: #00FF00;
}

.s {
background-color: #FF0000;
}

.c {
background-color: aqua;
}

.x {
background-color: pink;
}

.f {
background-color: gold;
}
</style>
<?php
echo "<pre><tt>";
echo join("<br/ >", $frame);
echo "</tt></pre>";

}
}


public static function serial($frame){
return gzcompress(join("\n", $frame), 9);
}
Expand All @@ -524,7 +451,7 @@ public static function newFrame($version){

if(!isset(self::$frames[$version])){

$fileName = SFQRCode::QR_CACHE_DIR . 'frame_' . $version . '.dat';
$fileName = SFQRCode::getInstance()->getDataFolder() . 'frame_' . $version . '.dat';

if(SFQRCode::QR_CACHEABLE){
if(file_exists($fileName)){
Expand Down
1 change: 1 addition & 0 deletions src/PeratX/SFQRCode/SFQRCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SFQRCode extends Module{

public function load(){
self::$obj = $this;
@mkdir($this->getDataFolder());
}

public static function getInstance(): SFQRCode{
Expand Down

0 comments on commit 6fe3fb9

Please sign in to comment.