All Projects → ChillingVan → Android Opengl Canvas

ChillingVan / Android Opengl Canvas

Licence: apache-2.0
An Android library that provides views using openGL canvas to draw things on SurfaceView or TextureView.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Opengl Canvas

Snapchat Clone
👻 A SnapChat clone built with React, Redux and Typescript. Styled with SASS. Tested with Cypress, Jest and Enzyme. Linted with Eslint and formatted with Prettier!
Stars: ✭ 770 (-5.52%)
Mutual labels:  camera, canvas
Ezfilter
A lightweight (<180KB), easy-to-extend Android filter and dynamic sticker framework for adding filters and stickers for camera, video, bitmap and view.(一个轻量级(<180KB)、易扩展的Android滤镜和动态贴纸框架,支持摄像头、视频、图片和视图添加滤镜和贴纸。)
Stars: ✭ 155 (-80.98%)
Mutual labels:  opengl, camera
Spectaculum
A spectacular view widget for visual media content on Android
Stars: ✭ 78 (-90.43%)
Mutual labels:  opengl, camera
React Native Gpuimage
GPUImage Component in React Native
Stars: ✭ 45 (-94.48%)
Mutual labels:  opengl, gpuimage
Android Ffmpeg Camerarecord
使用JavaCV提供的支持, 使用OpenGL实时处理+显示摄像头采集的图像, 并使用FFMPEG实时录制音视频
Stars: ✭ 334 (-59.02%)
Mutual labels:  opengl, camera
Android Gpuimage
Android filters based on OpenGL (idea from GPUImage for iOS)
Stars: ✭ 8,211 (+907.48%)
Mutual labels:  opengl, gpuimage
Androidcamera
🔥🔥🔥自定义Android相机(仿抖音 TikTok),其中功能包括视频人脸识别贴纸,美颜,分段录制,视频裁剪,视频帧处理,获取视频关键帧,视频旋转,添加滤镜,添加水印,合成Gif到视频,文字转视频,图片转视频,音视频合成,音频变声处理,SoundTouch,Fmod音频处理。 Android camera(imitation Tik Tok), which includes video editor,audio editor,video face recognition stickers, segment recording,video cropping, video frame processing, get the first video frame, key frame, v…
Stars: ✭ 2,112 (+159.14%)
Mutual labels:  opengl, camera
Ios tips
iOS的一些示例,持续更新中:1、AVFoundation 高仿微信相机拍摄和编辑 2、AVFoundation 人脸检测、实时滤镜、音视频编解码、GPUImage框架的使用等音视频相关内容 3、OpenGLES 4、LeetCode算法练习 5、iOS Crash防护和APM监控 6、WKWebView相关的内容 等........
Stars: ✭ 896 (+9.94%)
Mutual labels:  gpuimage, camera
TuSDK-for-Android-demo
TuSDK Android 图像 SDK Demo
Stars: ✭ 93 (-88.59%)
Mutual labels:  camera, gpuimage
Videocalling
局域网p2p视频聊天
Stars: ✭ 223 (-72.64%)
Mutual labels:  opengl, camera
Gpuimage X
A Cross-platform (for both Android & iOS) Framework for GPU-based Filters, Video and Image Processing.
Stars: ✭ 154 (-81.1%)
Mutual labels:  gpuimage, camera
Cameraview
📸 A well documented, high-level Android interface that makes capturing pictures and videos easy, addressing all of the common issues and needs. Real-time filters, gestures, watermarks, frame processing, RAW, output of any size.
Stars: ✭ 4,137 (+407.61%)
Mutual labels:  opengl, camera
Wslivedemo
音视频,直播SDK,rtmp推流,录制视频,滤镜。百万用户,线上迭代半年,已经稳定。
Stars: ✭ 1,782 (+118.65%)
Mutual labels:  gpuimage, camera
Opengl4android
OpenGL运用在Android上的Demo,结合Camera和MediaCodec实现预览和渲染,用于实现视频的裁剪,翻转,缩放,滤镜功能。
Stars: ✭ 56 (-93.13%)
Mutual labels:  opengl, camera
Kontax Cam
Instant camera hybrid with multiple effects and filters written in Swift.
Stars: ✭ 69 (-91.53%)
Mutual labels:  gpuimage, camera
Gcanvas
A lightweight cross-platform graphics rendering engine. (超轻量的跨平台图形引擎) https://alibaba.github.io/GCanvas
Stars: ✭ 1,705 (+109.2%)
Mutual labels:  opengl, canvas
Instacam
Instant canvas video
Stars: ✭ 106 (-86.99%)
Mutual labels:  camera, canvas
Smartopencv
🔥 🔥 🔥 SmartOpenCV是一个OpenCV在Android端的增强库,解决了OpenCV Android SDK在图像预览方面存在的诸多问题,且无需修改OpenCV SDK源码,与OpenCV的SDK解耦
Stars: ✭ 1,869 (+129.33%)
Mutual labels:  camera, canvas
Ios Gpuimage Plus
GPU accelerated image filters for iOS, based on OpenGL.
Stars: ✭ 217 (-73.37%)
Mutual labels:  opengl, gpuimage
Canvas
Canvas is a Go drawing library based on OpenGL or using software rendering that is very similar to the HTML5 canvas API
Stars: ✭ 358 (-56.07%)
Mutual labels:  opengl, canvas

OpenGL Canvas

English README

此项目灵感来源:

  • Android package com.android.gallery3d.glrenderer 下的源代码
  • GPUImage
  • grafika

感谢这些源代码提供者!

项目应用

功能

  • 提供一个类似Android Canvas类的使用OpenGL来实现绘制的canvasGL。可以像传统自定义View那样直接继承 GLViews, 再使用这个canvas绘制需要的东西。

  • 提供类似 GPUImage 里的Filter的API,可以在使用canvasGL画东西时实现图像处理。

  • 提供的View是继承 GLSurfaceView 或 TextureView 的,可以使用这两种View的特性,特别是TextureView的特性。

  • 另外,因为使用OpenGL在另一线程渲染,所以里面的 GLContinuousView 还提供能够实现高性能的动画的方法。(如果只要这个功能不要其它得话,那么我建议你直接继承View,见浅析Android的canvas性能anim

与GPUImage对比:

  • 提供无限循环渲染线程的 GLContinuousView 和 GLContinuousTextureView。
  • 使用TextureView来实现OpenGL的绘制,可以利用TextureView的优点--TextureView 不会创建一个分离的window,而是像一个普通的view那样显示, 这样就不会像GLSurfaceView那样,要么在所有View上方,要么被其它View遮住(看 setZOrderOnTop(boolean) 的说明)。而且像myView.setAlpha(0.5f)这种方法调用后也会有效果了。
  • 提供一个canvas,不只是图片处理,可以画上想画的其它东西。

使用要求

  • Android API 14 以上(OpenGL ES 2.0 以上)

用法

Gradle dependency

sample:

// in root build.gradle
allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

// module build.gradle
dependencies {
    implementation 'com.github.ChillingVan:android-openGL-canvas:v1.5.2.0'
}

样例代码

  • 自定义一个View.
public class MyGLView extends GLView {

    public MyGLView(Context context) {
        super(context);
    }

    public MyGLView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    protected void onGLDraw(ICanvasGL canvas) {
        // draw things with canvas here
    }
}

canvas

  • 其中, GLContinuouslyView, GLTextureView, GLContinuousTextureView, GLMultiTexProducerView and GLMultiTexConsumerView 用法相似.

  • 使用CanvasGL实现绘制

        canvas.drawBitmap(textBitmap, left, top);
        
        // transform
        canvas.save();
        canvas.rotate(rotateDegree, x, y);
        canvas.drawBitmap(bitmap, left, top);
        canvas.restore();
        // or
        CanvasGL.BitmapMatrix matrix = new CanvasGL.BitmapMatrix();
        matrix.postScale(2.1f, 2.1f);
        matrix.postRotate(90);
        canvas.drawBitmap(bitmap, matrix);
        
        // apply filter to the bitmap
        textureFilter = new ContrastFilter(2.8f);
        canvas.drawBitmap(bitmap, left, top, textureFilter);

filters

  • 可以与Camera结合,注意运行样例代码的时候尽量使用真机而不是模拟器。 camera

  • 如果不想使用View,可以使用 MultiTexOffScreenCanvas 实现脱离屏幕的绘制,然后使用getDrawingBitmap方法获取绘制的内容。

  • MediaPlayer

可以用 MediaPlayer 去解码视频,并绘制到 TextureView 上。 如果用本项目里的 GLSurfaceTextureProducerView ,那么还可以做视频处理。 结合AndroidInstantVideo的stream publisher,就能生成新视频。

  • AndroidCanvasHelper

这个GLCanvas不能绘制文本。只能先把文本转成Bitmap来绘制 可以使用AndroidCanvasHelper来画任意东西再转化为Bitmap给GLCanvas 这有同步和异步模式,视情况用对应的模式,详细请看例子。

注意事项和常见问题

  • 每一个View的onGLDraw都运行在自己的线程而非主线程。

  • 目前的Filter没有GPUImage里那么多,后续会陆续增加,如果有需要,参照我的代码自己实现即可,难度不高。

  • 为什么Bitmap修改后,再次绘制时并没更新?

    因为没有调用canvasGL的invalidateTextureContent(bitmap)。改变了的Bitmap需要重新绑定texture。因为绑定需要耗时,所以库里面才不做成每次都重新绑定。

相关博客文章

最近更新

  • 添加录屏demo
  • 添加clearTextureCache,比弱引用更快释放内存 (1.5.2)
  • AndroidCanvasHelper能直接操作Canvas里的bitmap了 (1.5.2)
  • TwoTextureFilter支持RawTexture了
  • drawSurfaceTexture也支持BitmapMatrix了
  • 添加OrthoBitmapMatrix以支持正交投影。 默认BitmapMatrix用的是透视投影。
  • 支持裁切图片的CropFilter
  • 增加 MultiTexOffScreenCanvas, GLMultiTexProducerView, GLMultiTexConsumerView,支持提供多张纹理的和消化多张纹理

License

Copyright 2016 ChillingVan.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on
 an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].