|
@@ -10,7 +10,6 @@ import com.bomostory.sceneeditmodule.basicdata.Scene
|
|
import kotlin.math.pow
|
|
import kotlin.math.pow
|
|
|
|
|
|
object SceneDrawer {
|
|
object SceneDrawer {
|
|
- lateinit var actorBitmap: Bitmap
|
|
|
|
fun drawScene(context: Context, scene: Scene, trackX: Int, scaleWidth: Int, scaleHeight: Int): Bitmap? {
|
|
fun drawScene(context: Context, scene: Scene, trackX: Int, scaleWidth: Int, scaleHeight: Int): Bitmap? {
|
|
var sceneBitmap: Bitmap? = null
|
|
var sceneBitmap: Bitmap? = null
|
|
|
|
|
|
@@ -22,7 +21,7 @@ object SceneDrawer {
|
|
for (layer in layers) {
|
|
for (layer in layers) {
|
|
for (actor in layer.actors) {
|
|
for (actor in layer.actors) {
|
|
if (!actor.isDialogue) {
|
|
if (!actor.isDialogue) {
|
|
- actorBitmap = BitmapFactory.decodeFile(actor.resourcePath)
|
|
|
|
|
|
+ var actorBitmap = BitmapFactory.decodeFile(actor.resourcePath)
|
|
actorBitmap = Bitmap.createScaledBitmap(actorBitmap, actor.sideLength, actor.sideHeight, true)
|
|
actorBitmap = Bitmap.createScaledBitmap(actorBitmap, actor.sideLength, actor.sideHeight, true)
|
|
|
|
|
|
canvas.save()
|
|
canvas.save()
|
|
@@ -30,7 +29,9 @@ object SceneDrawer {
|
|
canvas.drawBitmap(actorBitmap, actor.positionX.toFloat(), actor.positionY.toFloat(), Paint())
|
|
canvas.drawBitmap(actorBitmap, actor.positionX.toFloat(), actor.positionY.toFloat(), Paint())
|
|
canvas.restore()
|
|
canvas.restore()
|
|
|
|
|
|
- actorBitmap.recycle()
|
|
|
|
|
|
+ if (!actorBitmap.isRecycled) {
|
|
|
|
+ actorBitmap.recycle()
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
canvas.save()
|
|
canvas.save()
|
|
canvas.translate(trackX / 2f.pow(layers.indexOf(layer)), 0f)
|
|
canvas.translate(trackX / 2f.pow(layers.indexOf(layer)), 0f)
|