diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 7911e5d..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/example/flowershopapp/Database/AppDatabase.kt b/app/src/main/java/com/example/flowershopapp/Database/AppDatabase.kt index 196affd..08c6f9e 100644 --- a/app/src/main/java/com/example/flowershopapp/Database/AppDatabase.kt +++ b/app/src/main/java/com/example/flowershopapp/Database/AppDatabase.kt @@ -61,20 +61,22 @@ abstract class AppDatabase : RoomDatabase() { var image1 = converters.imageResourceToByteArray(appContext, R.drawable.image_bouquet1) var image2 = converters.imageResourceToByteArray(appContext, R.drawable.image_bouquet2) + val resizedImage1 = converters.resizeByteArrayImage(image1, 300, 300) + val resizedImage2 = converters.resizeByteArrayImage(image2, 300, 300) val bouquets = listOf( Bouquet( 1, "Bouquet1", 5, 3432, - image1, + resizedImage1, ), Bouquet( 2, "Bouquet2", 9, 2342, - image2, + resizedImage2, ) ) diff --git a/app/src/main/java/com/example/flowershopapp/Entities/Converters.kt b/app/src/main/java/com/example/flowershopapp/Entities/Converters.kt index e334514..3dea554 100644 --- a/app/src/main/java/com/example/flowershopapp/Entities/Converters.kt +++ b/app/src/main/java/com/example/flowershopapp/Entities/Converters.kt @@ -35,4 +35,13 @@ class Converters { bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream) return stream.toByteArray() } + fun resizeByteArrayImage(imageData: ByteArray, reqWidth: Int, reqHeight: Int): ByteArray { + val originalBitmap = BitmapFactory.decodeByteArray(imageData, 0, imageData.size) + + val resizedBitmap = Bitmap.createScaledBitmap(originalBitmap, reqWidth, reqHeight, true) + + val outputStream = ByteArrayOutputStream() + resizedBitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream) + return outputStream.toByteArray() + } } \ No newline at end of file