|
@@ -1,9 +1,6 @@
|
|
package com.bomostory.sceneeditmodule
|
|
package com.bomostory.sceneeditmodule
|
|
|
|
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Bitmap
|
|
-import android.graphics.BitmapFactory
|
|
|
|
-import android.graphics.Canvas
|
|
|
|
-import android.graphics.Paint
|
|
|
|
import android.util.Log
|
|
import android.util.Log
|
|
import com.bomostory.sceneeditmodule.MovieEditActivity.Companion.FPS
|
|
import com.bomostory.sceneeditmodule.MovieEditActivity.Companion.FPS
|
|
import com.bomostory.sceneeditmodule.basicdata.Music
|
|
import com.bomostory.sceneeditmodule.basicdata.Music
|
|
@@ -21,7 +18,6 @@ import java.util.concurrent.Semaphore
|
|
import kotlin.collections.ArrayList
|
|
import kotlin.collections.ArrayList
|
|
import kotlin.collections.LinkedHashMap
|
|
import kotlin.collections.LinkedHashMap
|
|
import kotlin.collections.set
|
|
import kotlin.collections.set
|
|
-import kotlin.math.pow
|
|
|
|
|
|
|
|
class SuperMovieMaker {
|
|
class SuperMovieMaker {
|
|
|
|
|
|
@@ -53,7 +49,7 @@ class SuperMovieMaker {
|
|
Completable.create {
|
|
Completable.create {
|
|
project?.story?.apply {
|
|
project?.story?.apply {
|
|
val scene = scenes[frameData.sceneIndex]
|
|
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()
|
|
movieBuilder.addImage(i, bitmap!!).blockingSubscribe()
|
|
}
|
|
}
|
|
it.onComplete()
|
|
it.onComplete()
|
|
@@ -128,7 +124,7 @@ class SuperMovieMaker {
|
|
return Observable.create<AbstractMap.SimpleEntry<Int, Bitmap>> {
|
|
return Observable.create<AbstractMap.SimpleEntry<Int, Bitmap>> {
|
|
scene?.apply {
|
|
scene?.apply {
|
|
record?.apply {
|
|
record?.apply {
|
|
- var bitmap = drawScene(scene, 0, scaleWidth, scaleHeight)
|
|
|
|
|
|
+ var bitmap = SceneDrawer.drawScene(scene, 0, scaleWidth, scaleHeight)
|
|
var bitmapIndex = 0
|
|
var bitmapIndex = 0
|
|
var trackPosition = -1
|
|
var trackPosition = -1
|
|
|
|
|
|
@@ -138,7 +134,7 @@ class SuperMovieMaker {
|
|
preBitmap = bitmap
|
|
preBitmap = bitmap
|
|
preBitmap?.recycle()
|
|
preBitmap?.recycle()
|
|
|
|
|
|
- bitmap = drawScene(scene, track.positionX, scaleWidth, scaleHeight)
|
|
|
|
|
|
+ bitmap = SceneDrawer.drawScene(scene, track.positionX, scaleWidth, scaleHeight)
|
|
trackPosition = tracks.indexOf(track)
|
|
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)
|
|
data class FrameData(val sceneIndex: Int, val x: Int, var repeat: Int)
|
|
}
|
|
}
|