Extract the data from QR Codes and create a new QR code with colour2019 Community Moderator ElectionGenerate QR Code with Colors in every pixel of image and binary valueStrange out of memory issue while loading an image to a Bitmap objectIs there a way to get the source code from an APK file?How do I get extra data from intent on Android?Why are my jpeg QR codes from ZXing not black and white?Invert pixels - zxingAndroid bitmap don't see black (astgmatic ? )Integrate ZXing in Android StudioColor value not valid — must be #rgb, #argb, #rrggbb, or #aarrggbbandroid: paint onto ARGB bitmap without changing alpha channelHow to create a QR code Generator for Android using Fragments
Are all passive ability checks floors for active ability checks?
What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?
Could the Saturn V actually have launched astronauts around Venus?
Do I need to be arrogant to get ahead?
PTIJ: Who should I vote for? (21st Knesset Edition)
While on vacation my taxi took a longer route, possibly to scam me out of money. How can I deal with this?
Explaining pyrokinesis powers
Why is a white electrical wire connected to 2 black wires?
What is the relationship between relativity and the Doppler effect?
Instead of a Universal Basic Income program, why not implement a "Universal Basic Needs" program?
How to write cleanly even if my character uses expletive language?
Adventure Game (text based) in C++
Describing a chess game in a novel
How to pronounce "I ♥ Huckabees"?
Does multi-classing into Fighter give you heavy armor proficiency?
What is a ^ b and (a & b) << 1?
Do the common programs (for example: "ls", "cat") in Linux and BSD come from the same source code?
Why Choose Less Effective Armour Types?
Why did it take so long to abandon sail after steamships were demonstrated?
How could an airship be repaired midflight?
Brexit - No Deal Rejection
Professor being mistaken for a grad student
Math equation in non italic font
World War I as a war of liberals against authoritarians?
Extract the data from QR Codes and create a new QR code with colour
2019 Community Moderator ElectionGenerate QR Code with Colors in every pixel of image and binary valueStrange out of memory issue while loading an image to a Bitmap objectIs there a way to get the source code from an APK file?How do I get extra data from intent on Android?Why are my jpeg QR codes from ZXing not black and white?Invert pixels - zxingAndroid bitmap don't see black (astgmatic ? )Integrate ZXing in Android StudioColor value not valid — must be #rgb, #argb, #rrggbb, or #aarrggbbandroid: paint onto ARGB bitmap without changing alpha channelHow to create a QR code Generator for Android using Fragments
Has anyone heard of this before ? Extract the QR
Codes
(all the QR Codes must be in same Width and Height square) and get the data from each QR Code
, and combine them. Then get the every pixel value from each QR Code and change them to hexadecimal
.
You will give #FFFFFFFF
, #FF000000
, #00000000
(white,black, transparent) and the like (but for black and white QR Code
, it would only 2 of them). Then for each value from each QR
Code, by creating a new colour QR Code
which the colour is according to the value from each hexadecimal and the content of the new colour QR Code
will have the content that was extracted from the previous QR Codes
.
For example, what I am doing now is extract 8 numbers of QR Code
and combine the content, then create a new colour QR Code
.
By now, I am stuck in the middle of the process. I have successfully extracted the content and the pixel of each QR Code
by changing the value to hexadecimal
. the problem is how can I can change the hexadecimal
value from each QR code
to ARGB
(alpha, Red, Green, Blue) colour and create a new colour QR Code
.
However, I have tip from Google, some say MatrixToImageWriter
would be useful. But there is not really much work there that is similar and useful to me. Well, I need some help here. However, I am not sure whether it will be useful for me or not.
PS: I can attach my work here if someone want to.
PSS: I am using the Zxing
library to scan and get the result from each QR Code
.
android qr-code zxing
add a comment |
Has anyone heard of this before ? Extract the QR
Codes
(all the QR Codes must be in same Width and Height square) and get the data from each QR Code
, and combine them. Then get the every pixel value from each QR Code and change them to hexadecimal
.
You will give #FFFFFFFF
, #FF000000
, #00000000
(white,black, transparent) and the like (but for black and white QR Code
, it would only 2 of them). Then for each value from each QR
Code, by creating a new colour QR Code
which the colour is according to the value from each hexadecimal and the content of the new colour QR Code
will have the content that was extracted from the previous QR Codes
.
For example, what I am doing now is extract 8 numbers of QR Code
and combine the content, then create a new colour QR Code
.
By now, I am stuck in the middle of the process. I have successfully extracted the content and the pixel of each QR Code
by changing the value to hexadecimal
. the problem is how can I can change the hexadecimal
value from each QR code
to ARGB
(alpha, Red, Green, Blue) colour and create a new colour QR Code
.
However, I have tip from Google, some say MatrixToImageWriter
would be useful. But there is not really much work there that is similar and useful to me. Well, I need some help here. However, I am not sure whether it will be useful for me or not.
PS: I can attach my work here if someone want to.
PSS: I am using the Zxing
library to scan and get the result from each QR Code
.
android qr-code zxing
1
+1, looking forward for the issue since i am interested on your question which seems like is combining the QR Code and get the larger QR code to store more data.
– David Adam
Mar 5 at 7:58
1
@Kopi Bryant "PS: I can attach my work here if someone want to" Yes, that would be helpful, (probably).
– Jon Goodwin
Mar 6 at 16:59
1
Give @Martin Zeitler his QR examples ;O)
– Jon Goodwin
Mar 6 at 17:02
add a comment |
Has anyone heard of this before ? Extract the QR
Codes
(all the QR Codes must be in same Width and Height square) and get the data from each QR Code
, and combine them. Then get the every pixel value from each QR Code and change them to hexadecimal
.
You will give #FFFFFFFF
, #FF000000
, #00000000
(white,black, transparent) and the like (but for black and white QR Code
, it would only 2 of them). Then for each value from each QR
Code, by creating a new colour QR Code
which the colour is according to the value from each hexadecimal and the content of the new colour QR Code
will have the content that was extracted from the previous QR Codes
.
For example, what I am doing now is extract 8 numbers of QR Code
and combine the content, then create a new colour QR Code
.
By now, I am stuck in the middle of the process. I have successfully extracted the content and the pixel of each QR Code
by changing the value to hexadecimal
. the problem is how can I can change the hexadecimal
value from each QR code
to ARGB
(alpha, Red, Green, Blue) colour and create a new colour QR Code
.
However, I have tip from Google, some say MatrixToImageWriter
would be useful. But there is not really much work there that is similar and useful to me. Well, I need some help here. However, I am not sure whether it will be useful for me or not.
PS: I can attach my work here if someone want to.
PSS: I am using the Zxing
library to scan and get the result from each QR Code
.
android qr-code zxing
Has anyone heard of this before ? Extract the QR
Codes
(all the QR Codes must be in same Width and Height square) and get the data from each QR Code
, and combine them. Then get the every pixel value from each QR Code and change them to hexadecimal
.
You will give #FFFFFFFF
, #FF000000
, #00000000
(white,black, transparent) and the like (but for black and white QR Code
, it would only 2 of them). Then for each value from each QR
Code, by creating a new colour QR Code
which the colour is according to the value from each hexadecimal and the content of the new colour QR Code
will have the content that was extracted from the previous QR Codes
.
For example, what I am doing now is extract 8 numbers of QR Code
and combine the content, then create a new colour QR Code
.
By now, I am stuck in the middle of the process. I have successfully extracted the content and the pixel of each QR Code
by changing the value to hexadecimal
. the problem is how can I can change the hexadecimal
value from each QR code
to ARGB
(alpha, Red, Green, Blue) colour and create a new colour QR Code
.
However, I have tip from Google, some say MatrixToImageWriter
would be useful. But there is not really much work there that is similar and useful to me. Well, I need some help here. However, I am not sure whether it will be useful for me or not.
PS: I can attach my work here if someone want to.
PSS: I am using the Zxing
library to scan and get the result from each QR Code
.
android qr-code zxing
android qr-code zxing
edited Mar 6 at 20:54
Martin Zeitler
19k34373
19k34373
asked Mar 4 at 7:26
Kopi BryantKopi Bryant
672220
672220
1
+1, looking forward for the issue since i am interested on your question which seems like is combining the QR Code and get the larger QR code to store more data.
– David Adam
Mar 5 at 7:58
1
@Kopi Bryant "PS: I can attach my work here if someone want to" Yes, that would be helpful, (probably).
– Jon Goodwin
Mar 6 at 16:59
1
Give @Martin Zeitler his QR examples ;O)
– Jon Goodwin
Mar 6 at 17:02
add a comment |
1
+1, looking forward for the issue since i am interested on your question which seems like is combining the QR Code and get the larger QR code to store more data.
– David Adam
Mar 5 at 7:58
1
@Kopi Bryant "PS: I can attach my work here if someone want to" Yes, that would be helpful, (probably).
– Jon Goodwin
Mar 6 at 16:59
1
Give @Martin Zeitler his QR examples ;O)
– Jon Goodwin
Mar 6 at 17:02
1
1
+1, looking forward for the issue since i am interested on your question which seems like is combining the QR Code and get the larger QR code to store more data.
– David Adam
Mar 5 at 7:58
+1, looking forward for the issue since i am interested on your question which seems like is combining the QR Code and get the larger QR code to store more data.
– David Adam
Mar 5 at 7:58
1
1
@Kopi Bryant "PS: I can attach my work here if someone want to" Yes, that would be helpful, (probably).
– Jon Goodwin
Mar 6 at 16:59
@Kopi Bryant "PS: I can attach my work here if someone want to" Yes, that would be helpful, (probably).
– Jon Goodwin
Mar 6 at 16:59
1
1
Give @Martin Zeitler his QR examples ;O)
– Jon Goodwin
Mar 6 at 17:02
Give @Martin Zeitler his QR examples ;O)
– Jon Goodwin
Mar 6 at 17:02
add a comment |
2 Answers
2
active
oldest
votes
I've just wrote the desired decode/encode methods; the matrix look different because I've created the input QR code with the QR Droid application and the output QR code with ZXing, which might use a different level of error correction; nevertheless both have the same destination URL, which is mine.
The dependencies originate from repositories google()
and mavenCentral()
:
dependencies
implementation "androidx.appcompat:appcompat:1.0.2"
// https://mvnrepository.com/artifact/com.google.zxing
implementation "com.google.zxing:core:3.3.3"
implementation "com.google.zxing:android-core:3.3.0"
The layout resource used:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/inputImage"
android:src="@drawable/qrcode"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/outputImage"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
And the manipulation of the BitMatrix
; where the encode()
method should suffice, when having the String
available; just added both methods for the sake of a complete example (it reads the Bitmap
from one AppCompatImageView
and then writes to another one AppCompatImageView
):
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
public class MainActivity extends AppCompatActivity
private AppCompatImageView mInputImage;
private AppCompatImageView mOutputImage;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_main);
this.mInputImage = this.findViewById(R.id.inputImage);
this.mOutputImage = this.findViewById(R.id.outputImage);
Bitmap bitmap = ((BitmapDrawable) this.mInputImage.getDrawable()).getBitmap();
String data = this.decode(bitmap);
bitmap = this.encode(data, bitmap.getWidth(), bitmap.getHeight(), 0xFFFFD034,0xFF06425C);
this.mOutputImage.setImageBitmap(bitmap);
private String decode(Bitmap bitmap)
String data = null;
MultiFormatReader reader = new MultiFormatReader();
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
BinaryBitmap binary = new BinaryBitmap(new HybridBinarizer(source));
try
Result result = reader.decode(binary);
data = result.getText();
catch (NotFoundException e)
e.printStackTrace();
Log.d("ZXing", "decoded: " + data);
return data;
private Bitmap encode(String contents, int width, int height, @ColorInt int foreground, @ColorInt int background)
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix matrix = null;
Bitmap bitmap = null;
try
matrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height);
catch (WriterException e)
e.printStackTrace();
if(matrix != null)
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++)
int offset = y * width;
for (int x = 0; x < width; x++)
pixels[offset + x] = matrix.get(x, y) ? foreground : background;
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
The result looks alike this; where the left one is the input matrix and the right one is the output matrix:
well, this is helpful. what if i want to set the pixel (e.g pixel[1][10] to blue color, pixel[20][20] to red color, some sort like this) of the qr code in the color i want ?
– Kopi Bryant
Mar 6 at 22:49
@KopiBryant you could add a method, which obtains a substitute color code for one of the colors (eg. by reading from a photo, by the current x/y coordinate). be aware, that the colors should start with0xFF
(zero transparency); also, color combinations which provide a low contrast might prevent the proper detection. complimentary colors should work well... and one can do an awful lot with QR (...), but the error correction still has it's limits.
– Martin Zeitler
Mar 6 at 23:15
see EncodeHintType for further settings one can pass into the MultiFormatWriter (after argumentheight
), which permits adjusting eg. the level of error correction - or the QR version, which to output.
– Martin Zeitler
Mar 6 at 23:29
well, it would be helpful and appreciated if there is some example code.
– Kopi Bryant
Mar 6 at 23:55
@KopiBryant wasn't part of the question, which I've already answered and even provided further clues... besides it is not even clear what the purpose is, of what you're trying to do. see meta.stackoverflow.com... and programming is my bread (as the example QR code might hint for), so I can't just go above and beyond of what was asked. asking a new question with a bounty might be your best chance to get such an example.
– Martin Zeitler
Mar 7 at 0:19
add a comment |
Well, after few days of digging from the Internet. I have found the solution and I think it would help someone else someday.
QRCodeWriter qw = new QRCodeWriter();
try
HashMap<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.MARGIN, margin);
BitMatrix matrix = qw.encode(msg, BarcodeFormat.QR_CODE, width, height, hints);
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
return bmp;
catch (WriterException e)
e.printStackTrace();
To change the color of the QR Code and if you have an arraylist
like mine that store all the hex
String. You can using for
loops and to insert the hex
String.
For changing the color, based on the code,
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
The Color.Black can be replace with the arraylist
(in my case, I replace it with my colorArray
) and Color.White is the color for the background of a QR Code.
Well, hope it helps someone somedays. Happy coding.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54978439%2fextract-the-data-from-qr-codes-and-create-a-new-qr-code-with-colour%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've just wrote the desired decode/encode methods; the matrix look different because I've created the input QR code with the QR Droid application and the output QR code with ZXing, which might use a different level of error correction; nevertheless both have the same destination URL, which is mine.
The dependencies originate from repositories google()
and mavenCentral()
:
dependencies
implementation "androidx.appcompat:appcompat:1.0.2"
// https://mvnrepository.com/artifact/com.google.zxing
implementation "com.google.zxing:core:3.3.3"
implementation "com.google.zxing:android-core:3.3.0"
The layout resource used:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/inputImage"
android:src="@drawable/qrcode"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/outputImage"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
And the manipulation of the BitMatrix
; where the encode()
method should suffice, when having the String
available; just added both methods for the sake of a complete example (it reads the Bitmap
from one AppCompatImageView
and then writes to another one AppCompatImageView
):
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
public class MainActivity extends AppCompatActivity
private AppCompatImageView mInputImage;
private AppCompatImageView mOutputImage;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_main);
this.mInputImage = this.findViewById(R.id.inputImage);
this.mOutputImage = this.findViewById(R.id.outputImage);
Bitmap bitmap = ((BitmapDrawable) this.mInputImage.getDrawable()).getBitmap();
String data = this.decode(bitmap);
bitmap = this.encode(data, bitmap.getWidth(), bitmap.getHeight(), 0xFFFFD034,0xFF06425C);
this.mOutputImage.setImageBitmap(bitmap);
private String decode(Bitmap bitmap)
String data = null;
MultiFormatReader reader = new MultiFormatReader();
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
BinaryBitmap binary = new BinaryBitmap(new HybridBinarizer(source));
try
Result result = reader.decode(binary);
data = result.getText();
catch (NotFoundException e)
e.printStackTrace();
Log.d("ZXing", "decoded: " + data);
return data;
private Bitmap encode(String contents, int width, int height, @ColorInt int foreground, @ColorInt int background)
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix matrix = null;
Bitmap bitmap = null;
try
matrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height);
catch (WriterException e)
e.printStackTrace();
if(matrix != null)
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++)
int offset = y * width;
for (int x = 0; x < width; x++)
pixels[offset + x] = matrix.get(x, y) ? foreground : background;
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
The result looks alike this; where the left one is the input matrix and the right one is the output matrix:
well, this is helpful. what if i want to set the pixel (e.g pixel[1][10] to blue color, pixel[20][20] to red color, some sort like this) of the qr code in the color i want ?
– Kopi Bryant
Mar 6 at 22:49
@KopiBryant you could add a method, which obtains a substitute color code for one of the colors (eg. by reading from a photo, by the current x/y coordinate). be aware, that the colors should start with0xFF
(zero transparency); also, color combinations which provide a low contrast might prevent the proper detection. complimentary colors should work well... and one can do an awful lot with QR (...), but the error correction still has it's limits.
– Martin Zeitler
Mar 6 at 23:15
see EncodeHintType for further settings one can pass into the MultiFormatWriter (after argumentheight
), which permits adjusting eg. the level of error correction - or the QR version, which to output.
– Martin Zeitler
Mar 6 at 23:29
well, it would be helpful and appreciated if there is some example code.
– Kopi Bryant
Mar 6 at 23:55
@KopiBryant wasn't part of the question, which I've already answered and even provided further clues... besides it is not even clear what the purpose is, of what you're trying to do. see meta.stackoverflow.com... and programming is my bread (as the example QR code might hint for), so I can't just go above and beyond of what was asked. asking a new question with a bounty might be your best chance to get such an example.
– Martin Zeitler
Mar 7 at 0:19
add a comment |
I've just wrote the desired decode/encode methods; the matrix look different because I've created the input QR code with the QR Droid application and the output QR code with ZXing, which might use a different level of error correction; nevertheless both have the same destination URL, which is mine.
The dependencies originate from repositories google()
and mavenCentral()
:
dependencies
implementation "androidx.appcompat:appcompat:1.0.2"
// https://mvnrepository.com/artifact/com.google.zxing
implementation "com.google.zxing:core:3.3.3"
implementation "com.google.zxing:android-core:3.3.0"
The layout resource used:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/inputImage"
android:src="@drawable/qrcode"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/outputImage"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
And the manipulation of the BitMatrix
; where the encode()
method should suffice, when having the String
available; just added both methods for the sake of a complete example (it reads the Bitmap
from one AppCompatImageView
and then writes to another one AppCompatImageView
):
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
public class MainActivity extends AppCompatActivity
private AppCompatImageView mInputImage;
private AppCompatImageView mOutputImage;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_main);
this.mInputImage = this.findViewById(R.id.inputImage);
this.mOutputImage = this.findViewById(R.id.outputImage);
Bitmap bitmap = ((BitmapDrawable) this.mInputImage.getDrawable()).getBitmap();
String data = this.decode(bitmap);
bitmap = this.encode(data, bitmap.getWidth(), bitmap.getHeight(), 0xFFFFD034,0xFF06425C);
this.mOutputImage.setImageBitmap(bitmap);
private String decode(Bitmap bitmap)
String data = null;
MultiFormatReader reader = new MultiFormatReader();
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
BinaryBitmap binary = new BinaryBitmap(new HybridBinarizer(source));
try
Result result = reader.decode(binary);
data = result.getText();
catch (NotFoundException e)
e.printStackTrace();
Log.d("ZXing", "decoded: " + data);
return data;
private Bitmap encode(String contents, int width, int height, @ColorInt int foreground, @ColorInt int background)
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix matrix = null;
Bitmap bitmap = null;
try
matrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height);
catch (WriterException e)
e.printStackTrace();
if(matrix != null)
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++)
int offset = y * width;
for (int x = 0; x < width; x++)
pixels[offset + x] = matrix.get(x, y) ? foreground : background;
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
The result looks alike this; where the left one is the input matrix and the right one is the output matrix:
well, this is helpful. what if i want to set the pixel (e.g pixel[1][10] to blue color, pixel[20][20] to red color, some sort like this) of the qr code in the color i want ?
– Kopi Bryant
Mar 6 at 22:49
@KopiBryant you could add a method, which obtains a substitute color code for one of the colors (eg. by reading from a photo, by the current x/y coordinate). be aware, that the colors should start with0xFF
(zero transparency); also, color combinations which provide a low contrast might prevent the proper detection. complimentary colors should work well... and one can do an awful lot with QR (...), but the error correction still has it's limits.
– Martin Zeitler
Mar 6 at 23:15
see EncodeHintType for further settings one can pass into the MultiFormatWriter (after argumentheight
), which permits adjusting eg. the level of error correction - or the QR version, which to output.
– Martin Zeitler
Mar 6 at 23:29
well, it would be helpful and appreciated if there is some example code.
– Kopi Bryant
Mar 6 at 23:55
@KopiBryant wasn't part of the question, which I've already answered and even provided further clues... besides it is not even clear what the purpose is, of what you're trying to do. see meta.stackoverflow.com... and programming is my bread (as the example QR code might hint for), so I can't just go above and beyond of what was asked. asking a new question with a bounty might be your best chance to get such an example.
– Martin Zeitler
Mar 7 at 0:19
add a comment |
I've just wrote the desired decode/encode methods; the matrix look different because I've created the input QR code with the QR Droid application and the output QR code with ZXing, which might use a different level of error correction; nevertheless both have the same destination URL, which is mine.
The dependencies originate from repositories google()
and mavenCentral()
:
dependencies
implementation "androidx.appcompat:appcompat:1.0.2"
// https://mvnrepository.com/artifact/com.google.zxing
implementation "com.google.zxing:core:3.3.3"
implementation "com.google.zxing:android-core:3.3.0"
The layout resource used:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/inputImage"
android:src="@drawable/qrcode"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/outputImage"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
And the manipulation of the BitMatrix
; where the encode()
method should suffice, when having the String
available; just added both methods for the sake of a complete example (it reads the Bitmap
from one AppCompatImageView
and then writes to another one AppCompatImageView
):
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
public class MainActivity extends AppCompatActivity
private AppCompatImageView mInputImage;
private AppCompatImageView mOutputImage;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_main);
this.mInputImage = this.findViewById(R.id.inputImage);
this.mOutputImage = this.findViewById(R.id.outputImage);
Bitmap bitmap = ((BitmapDrawable) this.mInputImage.getDrawable()).getBitmap();
String data = this.decode(bitmap);
bitmap = this.encode(data, bitmap.getWidth(), bitmap.getHeight(), 0xFFFFD034,0xFF06425C);
this.mOutputImage.setImageBitmap(bitmap);
private String decode(Bitmap bitmap)
String data = null;
MultiFormatReader reader = new MultiFormatReader();
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
BinaryBitmap binary = new BinaryBitmap(new HybridBinarizer(source));
try
Result result = reader.decode(binary);
data = result.getText();
catch (NotFoundException e)
e.printStackTrace();
Log.d("ZXing", "decoded: " + data);
return data;
private Bitmap encode(String contents, int width, int height, @ColorInt int foreground, @ColorInt int background)
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix matrix = null;
Bitmap bitmap = null;
try
matrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height);
catch (WriterException e)
e.printStackTrace();
if(matrix != null)
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++)
int offset = y * width;
for (int x = 0; x < width; x++)
pixels[offset + x] = matrix.get(x, y) ? foreground : background;
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
The result looks alike this; where the left one is the input matrix and the right one is the output matrix:
I've just wrote the desired decode/encode methods; the matrix look different because I've created the input QR code with the QR Droid application and the output QR code with ZXing, which might use a different level of error correction; nevertheless both have the same destination URL, which is mine.
The dependencies originate from repositories google()
and mavenCentral()
:
dependencies
implementation "androidx.appcompat:appcompat:1.0.2"
// https://mvnrepository.com/artifact/com.google.zxing
implementation "com.google.zxing:core:3.3.3"
implementation "com.google.zxing:android-core:3.3.0"
The layout resource used:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/inputImage"
android:src="@drawable/qrcode"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/outputImage"
android:layout_height="200dp"
android:layout_width="200dp"
android:padding="8dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
And the manipulation of the BitMatrix
; where the encode()
method should suffice, when having the String
available; just added both methods for the sake of a complete example (it reads the Bitmap
from one AppCompatImageView
and then writes to another one AppCompatImageView
):
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
public class MainActivity extends AppCompatActivity
private AppCompatImageView mInputImage;
private AppCompatImageView mOutputImage;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_main);
this.mInputImage = this.findViewById(R.id.inputImage);
this.mOutputImage = this.findViewById(R.id.outputImage);
Bitmap bitmap = ((BitmapDrawable) this.mInputImage.getDrawable()).getBitmap();
String data = this.decode(bitmap);
bitmap = this.encode(data, bitmap.getWidth(), bitmap.getHeight(), 0xFFFFD034,0xFF06425C);
this.mOutputImage.setImageBitmap(bitmap);
private String decode(Bitmap bitmap)
String data = null;
MultiFormatReader reader = new MultiFormatReader();
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
BinaryBitmap binary = new BinaryBitmap(new HybridBinarizer(source));
try
Result result = reader.decode(binary);
data = result.getText();
catch (NotFoundException e)
e.printStackTrace();
Log.d("ZXing", "decoded: " + data);
return data;
private Bitmap encode(String contents, int width, int height, @ColorInt int foreground, @ColorInt int background)
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix matrix = null;
Bitmap bitmap = null;
try
matrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height);
catch (WriterException e)
e.printStackTrace();
if(matrix != null)
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++)
int offset = y * width;
for (int x = 0; x < width; x++)
pixels[offset + x] = matrix.get(x, y) ? foreground : background;
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
The result looks alike this; where the left one is the input matrix and the right one is the output matrix:
edited Mar 6 at 21:03
answered Mar 6 at 19:46
Martin ZeitlerMartin Zeitler
19k34373
19k34373
well, this is helpful. what if i want to set the pixel (e.g pixel[1][10] to blue color, pixel[20][20] to red color, some sort like this) of the qr code in the color i want ?
– Kopi Bryant
Mar 6 at 22:49
@KopiBryant you could add a method, which obtains a substitute color code for one of the colors (eg. by reading from a photo, by the current x/y coordinate). be aware, that the colors should start with0xFF
(zero transparency); also, color combinations which provide a low contrast might prevent the proper detection. complimentary colors should work well... and one can do an awful lot with QR (...), but the error correction still has it's limits.
– Martin Zeitler
Mar 6 at 23:15
see EncodeHintType for further settings one can pass into the MultiFormatWriter (after argumentheight
), which permits adjusting eg. the level of error correction - or the QR version, which to output.
– Martin Zeitler
Mar 6 at 23:29
well, it would be helpful and appreciated if there is some example code.
– Kopi Bryant
Mar 6 at 23:55
@KopiBryant wasn't part of the question, which I've already answered and even provided further clues... besides it is not even clear what the purpose is, of what you're trying to do. see meta.stackoverflow.com... and programming is my bread (as the example QR code might hint for), so I can't just go above and beyond of what was asked. asking a new question with a bounty might be your best chance to get such an example.
– Martin Zeitler
Mar 7 at 0:19
add a comment |
well, this is helpful. what if i want to set the pixel (e.g pixel[1][10] to blue color, pixel[20][20] to red color, some sort like this) of the qr code in the color i want ?
– Kopi Bryant
Mar 6 at 22:49
@KopiBryant you could add a method, which obtains a substitute color code for one of the colors (eg. by reading from a photo, by the current x/y coordinate). be aware, that the colors should start with0xFF
(zero transparency); also, color combinations which provide a low contrast might prevent the proper detection. complimentary colors should work well... and one can do an awful lot with QR (...), but the error correction still has it's limits.
– Martin Zeitler
Mar 6 at 23:15
see EncodeHintType for further settings one can pass into the MultiFormatWriter (after argumentheight
), which permits adjusting eg. the level of error correction - or the QR version, which to output.
– Martin Zeitler
Mar 6 at 23:29
well, it would be helpful and appreciated if there is some example code.
– Kopi Bryant
Mar 6 at 23:55
@KopiBryant wasn't part of the question, which I've already answered and even provided further clues... besides it is not even clear what the purpose is, of what you're trying to do. see meta.stackoverflow.com... and programming is my bread (as the example QR code might hint for), so I can't just go above and beyond of what was asked. asking a new question with a bounty might be your best chance to get such an example.
– Martin Zeitler
Mar 7 at 0:19
well, this is helpful. what if i want to set the pixel (e.g pixel[1][10] to blue color, pixel[20][20] to red color, some sort like this) of the qr code in the color i want ?
– Kopi Bryant
Mar 6 at 22:49
well, this is helpful. what if i want to set the pixel (e.g pixel[1][10] to blue color, pixel[20][20] to red color, some sort like this) of the qr code in the color i want ?
– Kopi Bryant
Mar 6 at 22:49
@KopiBryant you could add a method, which obtains a substitute color code for one of the colors (eg. by reading from a photo, by the current x/y coordinate). be aware, that the colors should start with
0xFF
(zero transparency); also, color combinations which provide a low contrast might prevent the proper detection. complimentary colors should work well... and one can do an awful lot with QR (...), but the error correction still has it's limits.– Martin Zeitler
Mar 6 at 23:15
@KopiBryant you could add a method, which obtains a substitute color code for one of the colors (eg. by reading from a photo, by the current x/y coordinate). be aware, that the colors should start with
0xFF
(zero transparency); also, color combinations which provide a low contrast might prevent the proper detection. complimentary colors should work well... and one can do an awful lot with QR (...), but the error correction still has it's limits.– Martin Zeitler
Mar 6 at 23:15
see EncodeHintType for further settings one can pass into the MultiFormatWriter (after argument
height
), which permits adjusting eg. the level of error correction - or the QR version, which to output.– Martin Zeitler
Mar 6 at 23:29
see EncodeHintType for further settings one can pass into the MultiFormatWriter (after argument
height
), which permits adjusting eg. the level of error correction - or the QR version, which to output.– Martin Zeitler
Mar 6 at 23:29
well, it would be helpful and appreciated if there is some example code.
– Kopi Bryant
Mar 6 at 23:55
well, it would be helpful and appreciated if there is some example code.
– Kopi Bryant
Mar 6 at 23:55
@KopiBryant wasn't part of the question, which I've already answered and even provided further clues... besides it is not even clear what the purpose is, of what you're trying to do. see meta.stackoverflow.com... and programming is my bread (as the example QR code might hint for), so I can't just go above and beyond of what was asked. asking a new question with a bounty might be your best chance to get such an example.
– Martin Zeitler
Mar 7 at 0:19
@KopiBryant wasn't part of the question, which I've already answered and even provided further clues... besides it is not even clear what the purpose is, of what you're trying to do. see meta.stackoverflow.com... and programming is my bread (as the example QR code might hint for), so I can't just go above and beyond of what was asked. asking a new question with a bounty might be your best chance to get such an example.
– Martin Zeitler
Mar 7 at 0:19
add a comment |
Well, after few days of digging from the Internet. I have found the solution and I think it would help someone else someday.
QRCodeWriter qw = new QRCodeWriter();
try
HashMap<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.MARGIN, margin);
BitMatrix matrix = qw.encode(msg, BarcodeFormat.QR_CODE, width, height, hints);
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
return bmp;
catch (WriterException e)
e.printStackTrace();
To change the color of the QR Code and if you have an arraylist
like mine that store all the hex
String. You can using for
loops and to insert the hex
String.
For changing the color, based on the code,
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
The Color.Black can be replace with the arraylist
(in my case, I replace it with my colorArray
) and Color.White is the color for the background of a QR Code.
Well, hope it helps someone somedays. Happy coding.
add a comment |
Well, after few days of digging from the Internet. I have found the solution and I think it would help someone else someday.
QRCodeWriter qw = new QRCodeWriter();
try
HashMap<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.MARGIN, margin);
BitMatrix matrix = qw.encode(msg, BarcodeFormat.QR_CODE, width, height, hints);
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
return bmp;
catch (WriterException e)
e.printStackTrace();
To change the color of the QR Code and if you have an arraylist
like mine that store all the hex
String. You can using for
loops and to insert the hex
String.
For changing the color, based on the code,
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
The Color.Black can be replace with the arraylist
(in my case, I replace it with my colorArray
) and Color.White is the color for the background of a QR Code.
Well, hope it helps someone somedays. Happy coding.
add a comment |
Well, after few days of digging from the Internet. I have found the solution and I think it would help someone else someday.
QRCodeWriter qw = new QRCodeWriter();
try
HashMap<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.MARGIN, margin);
BitMatrix matrix = qw.encode(msg, BarcodeFormat.QR_CODE, width, height, hints);
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
return bmp;
catch (WriterException e)
e.printStackTrace();
To change the color of the QR Code and if you have an arraylist
like mine that store all the hex
String. You can using for
loops and to insert the hex
String.
For changing the color, based on the code,
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
The Color.Black can be replace with the arraylist
(in my case, I replace it with my colorArray
) and Color.White is the color for the background of a QR Code.
Well, hope it helps someone somedays. Happy coding.
Well, after few days of digging from the Internet. I have found the solution and I think it would help someone else someday.
QRCodeWriter qw = new QRCodeWriter();
try
HashMap<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.MARGIN, margin);
BitMatrix matrix = qw.encode(msg, BarcodeFormat.QR_CODE, width, height, hints);
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
return bmp;
catch (WriterException e)
e.printStackTrace();
To change the color of the QR Code and if you have an arraylist
like mine that store all the hex
String. You can using for
loops and to insert the hex
String.
For changing the color, based on the code,
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE);
The Color.Black can be replace with the arraylist
(in my case, I replace it with my colorArray
) and Color.White is the color for the background of a QR Code.
Well, hope it helps someone somedays. Happy coding.
answered Mar 10 at 17:52
Kopi BryantKopi Bryant
672220
672220
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54978439%2fextract-the-data-from-qr-codes-and-create-a-new-qr-code-with-colour%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
+1, looking forward for the issue since i am interested on your question which seems like is combining the QR Code and get the larger QR code to store more data.
– David Adam
Mar 5 at 7:58
1
@Kopi Bryant "PS: I can attach my work here if someone want to" Yes, that would be helpful, (probably).
– Jon Goodwin
Mar 6 at 16:59
1
Give @Martin Zeitler his QR examples ;O)
– Jon Goodwin
Mar 6 at 17:02