|
@@ -1,9 +1,6 @@
|
|
|
package com.bomostory.sceneeditmodule
|
|
|
|
|
|
import android.graphics.Bitmap
|
|
|
-import android.graphics.BitmapFactory
|
|
|
-import android.graphics.Canvas
|
|
|
-import android.graphics.Paint
|
|
|
import android.util.Log
|
|
|
import com.bomostory.sceneeditmodule.MovieEditActivity.Companion.FPS
|
|
|
import com.bomostory.sceneeditmodule.basicdata.Music
|
|
@@ -21,7 +18,6 @@ import java.util.concurrent.Semaphore
|
|
|
import kotlin.collections.ArrayList
|
|
|
import kotlin.collections.LinkedHashMap
|
|
|
import kotlin.collections.set
|
|
|
-import kotlin.math.pow
|
|
|
|
|
|
class SuperMovieMaker {
|
|
|
|
|
@@ -53,7 +49,7 @@ class SuperMovieMaker {
|
|
|
Completable.create {
|
|
|
project?.story?.apply {
|
|
|
val scene = scenes[frameData.sceneIndex]
|
|
|
- val bitmap = drawScene(scene, frameData.x, scaleWidth, scaleHeight)
|
|
|
+ val bitmap = SceneDrawer.drawScene(scene, frameData.x, scaleWidth, scaleHeight)
|
|
|
movieBuilder.addImage(i, bitmap!!).blockingSubscribe()
|
|
|
}
|
|
|
it.onComplete()
|
|
@@ -128,7 +124,7 @@ class SuperMovieMaker {
|
|
|
return Observable.create<AbstractMap.SimpleEntry<Int, Bitmap>> {
|
|
|
scene?.apply {
|
|
|
record?.apply {
|
|
|
- var bitmap = drawScene(scene, 0, scaleWidth, scaleHeight)
|
|
|
+ var bitmap = SceneDrawer.drawScene(scene, 0, scaleWidth, scaleHeight)
|
|
|
var bitmapIndex = 0
|
|
|
var trackPosition = -1
|
|
|
|
|
@@ -138,7 +134,7 @@ class SuperMovieMaker {
|
|
|
preBitmap = bitmap
|
|
|
preBitmap?.recycle()
|
|
|
|
|
|
- bitmap = drawScene(scene, track.positionX, scaleWidth, scaleHeight)
|
|
|
+ bitmap = SceneDrawer.drawScene(scene, track.positionX, scaleWidth, scaleHeight)
|
|
|
trackPosition = tracks.indexOf(track)
|
|
|
}
|
|
|
}
|
|
@@ -153,30 +149,6 @@ class SuperMovieMaker {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun drawScene(scene: Scene, trackX: Int, scaleWidth: Int, scaleHeight: Int): Bitmap? {
|
|
|
- var sceneBitmap: Bitmap? = null
|
|
|
-
|
|
|
- scene?.apply {
|
|
|
- sceneBitmap = BitmapFactory.decodeFile(backgroundPath)
|
|
|
- sceneBitmap = Bitmap.createScaledBitmap(sceneBitmap, scaleWidth, scaleHeight, true)
|
|
|
-
|
|
|
- val canvas = Canvas(sceneBitmap)
|
|
|
- for (layer in layers) {
|
|
|
- for (actor in layer.actors) {
|
|
|
- var actorBitmap = BitmapFactory.decodeFile(actor.resourcePath)
|
|
|
- actorBitmap = Bitmap.createScaledBitmap(actorBitmap, actor.sideLength, actor.sideLength, true)
|
|
|
-
|
|
|
- canvas.save()
|
|
|
- canvas.translate(trackX / 2f.pow(layers.indexOf(layer)), 0f)
|
|
|
- canvas.drawBitmap(actorBitmap, actor.positionX.toFloat(), actor.positionY.toFloat(), Paint())
|
|
|
- canvas.restore()
|
|
|
-
|
|
|
- actorBitmap.recycle()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return sceneBitmap
|
|
|
- }
|
|
|
|
|
|
data class FrameData(val sceneIndex: Int, val x: Int, var repeat: Int)
|
|
|
}
|