当前位置:网站首页>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
边栏推荐
- Raspberry pie uses root operation, and the graphical interface uses its own file manager
- The flyer realizes page Jump through routing routes
- SSDB Foundation
- c1000k TCP 连接上限测试
- MySQL Téléchargement et installation de la version Linux
- Audio signal processing and coding - 2.5.3 the discrete cosine transform
- Use of fluent custom fonts and pictures
- Common SQL commands
- 2022.04.23 (lc_763_divided into letter interval)
- Introduction to micro build low code zero Foundation (lesson 3)
猜你喜欢
浅谈c语言指针的强制转换
为何PostgreSQL即将超越SQL Server?
12 examples to consolidate promise Foundation
One of the reasons why the WebView web page cannot be opened (and some WebView problem records encountered by myself)
ArcMap publishing slicing service
Keysight has chosen what equipment to buy for you
Esp01s with Arduino development environment
Oracle配置st_geometry
An idea of rendering pipeline based on FBO
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
随机推荐
Redis optimization series (III) solve common problems after master-slave configuration
[记录]TypeError: this.getOptions is not a function
WebView opens H5 video and displays gray background or black triangle button. Problem solved
MySQL restores or rolls back data through binlog
How about CICC wealth? Is it safe to open an account up there
On the forced conversion of C language pointer
Modify the font size of hint in editext
电路在线模拟
SQL of contention for system time plus time in ocrale database
Use of fluent custom fonts and pictures
为何PostgreSQL即将超越SQL Server?
[report] Microsoft: application of deep learning methods in speech enhancement
Using Visual Studio code to develop Arduino
微搭低代码零基础入门课(第三课)
Zlib realizes streaming decompression
Audio signal processing and coding - 2.5.3 the discrete cosine transform
The flyer realizes page Jump through routing routes
Esp01s with Arduino development environment
: app: transformclasseswithrobustfordevrease meituan hot repair compilation error record
c#:泛型反射