-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add url QR code on web on pc interface. #188
- Loading branch information
1 parent
5f4e199
commit c51de94
Showing
3 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/ismartcoding/plain/helpers/QrCodeGenerateHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.ismartcoding.plain.helpers | ||
|
||
import android.graphics.Bitmap | ||
import com.google.zxing.BarcodeFormat | ||
import com.google.zxing.MultiFormatWriter | ||
|
||
object QrCodeGenerateHelper { | ||
fun generate(text: String, width: Int, height: Int): Bitmap { | ||
val bitMatrix = MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, width, height) | ||
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565) | ||
for (x in 0 until width) { | ||
for (y in 0 until height) { | ||
bitmap.setPixel(x, y, if (bitMatrix.get(x, y)) android.graphics.Color.BLACK else android.graphics.Color.WHITE) | ||
} | ||
} | ||
return bitmap | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters