Compare commits
1 Commits
ivan/use-p
...
fix/androi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c8d503e66 |
@@ -30,7 +30,7 @@ fun rotateBitmap90CounterClockwise(source: Bitmap): Bitmap {
|
|||||||
val height = source.height
|
val height = source.height
|
||||||
|
|
||||||
// Create a new Bitmap with swapped width and height
|
// Create a new Bitmap with swapped width and height
|
||||||
val rotatedBitmap = Bitmap.createBitmap(height, width, source.config)
|
val rotatedBitmap = Bitmap.createBitmap(height, width, source.config ?: Bitmap.Config.ARGB_8888)
|
||||||
|
|
||||||
for (y in 0 until height) {
|
for (y in 0 until height) {
|
||||||
for (x in 0 until width) {
|
for (x in 0 until width) {
|
||||||
@@ -48,7 +48,7 @@ fun Bitmap.transformBitmap(orientation: Orientation): Bitmap {
|
|||||||
Orientation.PORTRAIT -> this // No transformation needed
|
Orientation.PORTRAIT -> this // No transformation needed
|
||||||
Orientation.LANDSCAPE_LEFT -> {
|
Orientation.LANDSCAPE_LEFT -> {
|
||||||
// Transpose (swap width and height)
|
// Transpose (swap width and height)
|
||||||
val transposedBitmap = Bitmap.createBitmap(height, width, config)
|
val transposedBitmap = Bitmap.createBitmap(height, width, config ?: Bitmap.Config.ARGB_8888)
|
||||||
for (y in 0 until height) {
|
for (y in 0 until height) {
|
||||||
for (x in 0 until width) {
|
for (x in 0 until width) {
|
||||||
transposedBitmap.setPixel(y, width - 1 - x, getPixel(x, y))
|
transposedBitmap.setPixel(y, width - 1 - x, getPixel(x, y))
|
||||||
@@ -58,7 +58,7 @@ fun Bitmap.transformBitmap(orientation: Orientation): Bitmap {
|
|||||||
}
|
}
|
||||||
Orientation.PORTRAIT_UPSIDE_DOWN -> {
|
Orientation.PORTRAIT_UPSIDE_DOWN -> {
|
||||||
// Invert vertically and horizontally (180-degree rotation)
|
// Invert vertically and horizontally (180-degree rotation)
|
||||||
val invertedBitmap = Bitmap.createBitmap(width, height, config)
|
val invertedBitmap = Bitmap.createBitmap(width, height, config ?: Bitmap.Config.ARGB_8888)
|
||||||
for (y in 0 until height) {
|
for (y in 0 until height) {
|
||||||
for (x in 0 until width) {
|
for (x in 0 until width) {
|
||||||
invertedBitmap.setPixel(width - 1 - x, height - 1 - y, getPixel(x, y))
|
invertedBitmap.setPixel(width - 1 - x, height - 1 - y, getPixel(x, y))
|
||||||
@@ -68,7 +68,7 @@ fun Bitmap.transformBitmap(orientation: Orientation): Bitmap {
|
|||||||
}
|
}
|
||||||
Orientation.LANDSCAPE_RIGHT -> {
|
Orientation.LANDSCAPE_RIGHT -> {
|
||||||
// Transpose (swap width and height) and invert vertically
|
// Transpose (swap width and height) and invert vertically
|
||||||
val transposedBitmap = Bitmap.createBitmap(height, width, config)
|
val transposedBitmap = Bitmap.createBitmap(height, width, config ?: Bitmap.Config.ARGB_8888)
|
||||||
for (y in 0 until height) {
|
for (y in 0 until height) {
|
||||||
for (x in 0 until width) {
|
for (x in 0 until width) {
|
||||||
transposedBitmap.setPixel(height - 1 - y, x, getPixel(x, y))
|
transposedBitmap.setPixel(height - 1 - y, x, getPixel(x, y))
|
||||||
|
|||||||
Reference in New Issue
Block a user