mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Bitmap manipulation.
This commit is contained in:
@@ -22,7 +22,7 @@ add_library(hello-tinyusdz SHARED
|
||||
${TINYUSDZ_DEP_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(hello-tinyusdz android log)
|
||||
target_link_libraries(hello-tinyusdz jnigraphics android log)
|
||||
target_include_directories(hello-tinyusdz PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/../../../../../src/
|
||||
${PROJECT_SOURCE_DIR}/../../../../../src/external/ryu
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
#include <android/bitmap.h>
|
||||
#include <android/asset_manager.h>
|
||||
#include <android/asset_manager_jni.h>
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.BitmapFactory
|
||||
import kotlinx.android.synthetic.main.activity_main.sample_text
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
@@ -32,6 +36,25 @@ class MainActivity : AppCompatActivity() {
|
||||
setContentView(R.layout.activity_main)
|
||||
val view = findViewById<View>(R.id.container)
|
||||
|
||||
var conf = Bitmap.Config.ARGB_8888
|
||||
var b = Bitmap.createBitmap(512, 512, conf)
|
||||
|
||||
var pixels = IntArray(512 * 512)
|
||||
|
||||
b.getPixels(pixels, 0,512, 0, 0, 512, 512)
|
||||
|
||||
for (y in 0 until 512) {
|
||||
for (x in 0 until 512) {
|
||||
pixels[y * 512 + x] = Color.argb(125, x % 256, y % 256, 64)
|
||||
}
|
||||
}
|
||||
|
||||
b.setPixels(pixels, 0, 512, 0, 0, 512, 512)
|
||||
|
||||
var img = findViewById<ImageView>(R.id.imageView)
|
||||
|
||||
img.setImageBitmap(b)
|
||||
|
||||
// Set up a touch listener which calls the native sound engine
|
||||
view.setOnTouchListener {_, event ->
|
||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||
|
||||
@@ -17,4 +17,14 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_launcher_background" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user