当前位置:网站首页>An example of using JNI to directly access surface data
An example of using JNI to directly access surface data
2022-04-23 19:14:00 【cjzcjl】
For example, this can give Surface Fill in blue :
///* Pass in surface Examples of direct drawing , The incoming color covers the whole surface */
JNIEXPORT void JNICALL
Java_com_opengldecoder_jnibridge_JniBridge_drawToSurface(JNIEnv *env, jobject activity,
jobject surface, jint color) {
ANativeWindow_Buffer nwBuffer;
LOGI("ANativeWindow_fromSurface ");
ANativeWindow *mANativeWindow = ANativeWindow_fromSurface(env, surface);
if (mANativeWindow == NULL) {
LOGE("ANativeWindow_fromSurface error");
return;
}
LOGI("ANativeWindow_lock ");
if (0 != ANativeWindow_lock(mANativeWindow, &nwBuffer, 0)) {
LOGE("ANativeWindow_lock error");
return;
}
LOGI("ANativeWindow_lock nwBuffer->format ");
if (nwBuffer.format == WINDOW_FORMAT_RGB_565) {
int y, x;
LOGI("nwBuffer->format == WINDOW_FORMAT_RGB_565");
memset(nwBuffer.bits, color << 8, sizeof(__uint16_t) * nwBuffer.height * nwBuffer.width);
} else if (nwBuffer.format == WINDOW_FORMAT_RGBA_8888) {
LOGI("nwBuffer->format == WINDOW_FORMAT_RGBA_8888 ");
memset(nwBuffer.bits, color, sizeof(__uint32_t) * nwBuffer.height * nwBuffer.width);
}
LOGI("ANativeWindow_unlockAndPost ");
if (0 != ANativeWindow_unlockAndPost(mANativeWindow)) {
LOGE("ANativeWindow_unlockAndPost error");
return;
}
ANativeWindow_release(mANativeWindow);
LOGI("ANativeWindow_release ");
}
版权声明
本文为[cjzcjl]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210600587547.html
边栏推荐
- Customize the non slidable viewpage and how to use it
- JS controls the file type and size when uploading files
- How to uninstall easyton
- Getting started with vcpkg
- Redis optimization series (III) solve common problems after master-slave configuration
- 8266 obtain 18b20 temperature
- 【C语言进阶11——字符和字符串函数及其模拟实现(2))】
- 2022.04.23(LC_714_买卖股票的最佳时机含手续费)
- Screen right-click menu in souI
- openlayers 5.0 当地图容器大小改变时,重新加载地图
猜你喜欢

Partage de la conception de l'alimentation électrique de commutation et illustration des compétences en conception de l'alimentation électrique

redis优化系列(三)解决主从配置后的常见问题

剑指 Offer II 116. 省份数量-空间复杂度O(n),时间复杂度O(n)

2022.04.23 (lc_763_divided into letter interval)

Esp01s with Arduino development environment

浅谈c语言指针的强制转换

OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!

FTP、ssh远程访问及控制

The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics

White screen processing method of fulter startup page
随机推荐
Codeforces Round #783 (Div. 2) D题解
12 examples to consolidate promise Foundation
Solve the problem of invalid listview Click
mysql_ Download and installation of Linux version
Using Visual Studio code to develop Arduino
The difference between ordinary inner class and static inner class
The type initializer for ‘Gdip‘ threw an exception
Codeforces Round #784 (Div. 4)
数据分析学习目录
Use of fluent custom fonts and pictures
SQL Server database in clause and exists clause conversion
Speculation on the way to realize the smooth drag preview of video editing software
深度学习环境搭建步骤—gpu
Some records used by VS2010
openlayers 5.0 当地图容器大小改变时,重新加载地图
【C语言进阶11——字符和字符串函数及其模拟实现(2))】
Network protocol: SCTP flow control transmission protocol
Tencent map and high logo removal method
Minesweeping II of souI instance
MySQL statement