Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfan committed Nov 7, 2016
1 parent c9d9814 commit 7413551
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# GPUImage for Android

Idea from:
* Codes of Android source code under package com.android.gallery3d.glrenderer
* [GPUImage](https://github.com/CyberAgent/android-gpuimage)
* [grafika](https://github.com/google/grafika)

## Features
* This canvas provide similar API as android canvas. And there are GLViews that can be extended to custom your own view to draw things with OpenGL.
* Similar to the filters of GPUImage, you can apply the filter to the bitmap draw into the GLViews.
* Provides GLViews that using GLSurfaceView and TextureView.
* The GLContinuousView can provide high performance continuous rendering animation.

## Requirements
* Android API14 or higher (OpenGL ES 2.0)

## Usage

### Gradle dependency

```groovy
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.ChillingVan:CanvasGL:1.0.1'
}
```

### Sample Code

Custom your view.
```java
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
}
}
```

![camera](https://github.com/ChillingVan/android-openGL-canvas/raw/master/screenshots/camera-example.jpg)


The Usage of GLContinuouslyView, GLTextureView, GLContinuousTextureView, GLSurfaceTextureProducerView and GLSharedContextView is similar.


Using canvas to draw
```java
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](https://github.com/ChillingVan/android-openGL-canvas/raw/master/screenshots/filter_example.png)
![canvas](https://github.com/ChillingVan/android-openGL-canvas/raw/master/screenshots/canvas-example.png)


And can be used with camera, just run the camera sample code on a real device(not in emulator) to see what will happen.

## License
Copyright 2012 CyberAgent, Inc.

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.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
5 changes: 2 additions & 3 deletions canvasgl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.ChillingVan'

android {
compileSdkVersion 24
Expand All @@ -38,9 +40,6 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}
Binary file added screenshots/camera-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/canvas-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/filter_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7413551

Please sign in to comment.