This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 略過相關的 C、Jni 類型轉換 | |
void Sample::ConvertBase64ToTexture2D(FString base64Str) | |
{ | |
TArray<uint8> sourceData; | |
FBase64::Decode(base64Str, sourceData); | |
UTexture2D* outTexture = FImageUtils::ImportBufferAsTexture2D(sourceData); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 處理傳來的 base64 | |
/// </summary> | |
/// <param name="base64Str">圖片資訊</param> | |
private void ConvertBase64ToBytes(string base64Str) | |
{ | |
byte[] bytes = System.Convert.FromBase64String(base64Str); | |
ConvertBytesToTexture(bytes); | |
} | |
/// <summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 選擇照片的 Callback | |
private void onSelectPhotoSuccess(Bitmap bitmap) | |
{ | |
float quality = 80; | |
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |
bitmap.compress(Bitmap.CompressFormat.PNG, quality, out); | |
sendPhotoDataToEngine(out.toByteArray()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 選擇照片的 Callback | |
-(void)onSelectPhotoSuccess:(UIImage*)choseImage | |
{ | |
// 壓縮值(%) | |
CGFloat quality = 0.8; | |
// Convert image to NSData | |
NSData* data = UIImageJPEGRepresentation(choseImage, quality); | |
[self sendPhotoDataToEngine: data]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun HelloScreen() { | |
var name by rememberSaveable { mutableStateOf("") } | |
HelloContent(name = name, onNameChange = { name = it }) | |
} | |
@Composable | |
fun HelloContent(name: String, onNameChange: (String) -> Unit) { | |
Column(modifier = Modifier.padding(16.dp)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by 委派需要 import 以下 | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.setValue | |
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun HelloContent() { | |
Column(modifier = Modifier.padding(16.dp)) { | |
var name: String by remember { mutableStateOf("") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun HelloContent() { | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( | |
text = "Hello", | |
modifier = Modifier.padding(bottom = 8.dp), | |
style = MaterialTheme.typography.bodyMedium | |
) | |
OutlinedTextField( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val viewModel: ConversationViewModel = viewModel() | |
val messages by viewModel.messages.observeAsState() | |
MessageList(messages) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MessageList(messages: List<String>) { | |
Column { | |
if (messages.size == 0) { | |
Text(text = "No messages") | |
} else { | |
messages.forEach { message -> | |
Text(text = message) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool taskCompleted = false; | |
void setup() { | |
Serial.begin(115200); | |
connectToWiFi(); | |
connectToServer(); | |
} | |
void loop() { | |
if (Firebase.ready() && !taskCompleted) { |
NewerOlder