package Data::QRCode; use strict; use warnings; # ABSTRACT: qrcodes in C # VERSION use Data::QRCode::Inline with => 'Alien::QREncode'; use Data::QRCode::Inline C => ( 'DATA', autowrap => 1, typemaps => 'typemap', ); sub new { my ($class, $input) = @_; my $self = QRcode_encodeInput($input); bless $self, $class; return $self; } sub data_at { my ($self,$x,$y) = @_; my $width = $self->width; if ($x < 0 or $x >= $width or $y < 0 or $y >= $width) { return; } my $value = _data_at($self,$x,$y); return { color => $value & 0x01, in_data => $value & 0x02, in_format => $value & 0x04, in_version => $value & 0x08, in_timing => $value & 0x10, in_alignment => $value & 0x20, in_finder => $value & 0x40, in_misc => $value & 0x80, }; } 1; __DATA__ __C__ QRcode *QRcode_encodeInput(QRinput *input); void DESTROY(QRcode *qrcode) { QRcode_free(qrcode); } int version(QRcode* self) { return self->version; } int width(QRcode* self) { return self->width; } int _data_at(QRcode* self, int x, int y) { return self->data[x+y*self->width]; }