Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMartin committed Jan 21, 2023
1 parent 640444e commit ce7d423
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/cz/utb/photostudio/EditorFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class EditorFragment : Fragment() {

// ulozi obrazek do galerie i s filtrama
binding.buttonExport.setOnClickListener {
this.image?.let { it1 -> ImageIO.exportImageToGallery(requireContext(), it1, true) }
this.image?.let { it1 -> ImageIO.exportImageToGallery(requireContext(), it1, this.filterListAdapter?.getFilterList()) }
}

// ulozi filtry obrazku do databaze
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/cz/utb/photostudio/ImageFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ImageFragment : Fragment() {

// exportuje obrazek do galerie
binding.buttonExport.setOnClickListener {
this.image?.let { it1 -> ImageIO.exportImageToGallery(requireContext(), it1, false) }
this.image?.let { it1 -> ImageIO.exportImageToGallery(requireContext(), it1, null) }
}

// odstraneni tohoto obrazku
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/java/cz/utb/photostudio/util/ImageIO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,17 @@ class ImageIO {
}
}

fun exportImageToGallery(context: Context, image: ImageFile, applyFilters: Boolean) {
fun exportImageToGallery(context: Context, image: ImageFile, filters: List<Filter>?) {
Executors.newSingleThreadExecutor().execute {
try {
// load img from local file system
val bitmap: Bitmap? = loadImage(context, image.imagePath)

// load filters from db and apply tham on img
if(applyFilters) {
val db: AppDatabase = AppDatabase.getDatabase(context)
val filters: FilterPersistentDao = db.filterPersistentDao()

if(filters != null) {
val matrix = ColorMatrix()
for(fp in filters.getAllWithImageUID(image!!.uid)) {
val f: Filter? = fp.createFilter()
f?.applyFilter(matrix)
for(f in filters) {
f.applyFilter(matrix)
}

// apply color matrix
Expand Down
Binary file added doc/img1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce7d423

Please sign in to comment.