Skip to content

Improve file size of output from DrawingFragment #20930

@david-allison

Description

@david-allison

https://www.reddit.com/r/Anki/comments/1t1qpzm/does_drawing_picture_instead_of_adding_the_image/

We save the Whiteboard as JPG with quality 95.

private fun saveWhiteboard(view: WhiteboardView): Uri {
val bitmap = createBitmap(view.width, view.height)
val canvas = Canvas(bitmap)
val backgroundColor =
if (Themes.isNightTheme) {
Color.BLACK
} else {
Color.WHITE
}
canvas.drawColor(backgroundColor)
view.draw(canvas)
val baseFileName = "Whiteboard" + getTimestamp(TimeManager.time)
return CompatHelper.compat.saveImage(requireContext(), bitmap, baseFileName, "jpg", Bitmap.CompressFormat.JPEG, 95)
}


  • Create a few images and see the sizes, determine if this is a problem
    • Reported sizes of 300KB on reddit - likely an issue
    • See below. Ouch
  1. Determine the output file we want
    • I suspect we should generate a SVG, since the file should be moved to collection.media

Metadata

Metadata

Assignees

Labels

No labels
No labels

Priority

Medium

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions