android gpuimage
1.0.0
アイデア元: iOS GPUImage フレームワーク
目標は、GPUImage にできるだけ似たものを用意することです。頂点シェーダーとフラグメントシェーダーはまったく同じです。そうすることで、GPUImage iOS から Android へのフィルタの移植が容易になります。
repositories {
mavenCentral()
}
dependencies {
implementation ' jp.co.cyberagent.android:gpuimage:2.x.x '
}
ジャバ:
@ Override
public void onCreate ( final Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState );
setContentView ( R . layout . activity );
Uri imageUri = ...;
gpuImage = new GPUImage ( this );
gpuImage . setGLSurfaceView (( GLSurfaceView ) findViewById ( R . id . surfaceView ));
gpuImage . setImage ( imageUri ); // this loads image on the current thread, should be run in a thread
gpuImage . setFilter ( new GPUImageSepiaFilter ());
// Later when image should be saved saved:
gpuImage . saveToPictures ( "GPUImage" , "ImageWithFilter.jpg" , null );
}
コトリン:
public override fun onCreate ( savedInstanceState : Bundle ? ) {
super .onCreate(savedInstanceState)
setContentView( R .layout.activity_gallery)
val imageUri : Uri = .. .
gpuImage = GPUImage ( this )
gpuImage.setGLSurfaceView(findViewById< GLSurfaceView >( R .id.surfaceView))
gpuImage.setImage(imageUri) // this loads image on the current thread, should be run in a thread
gpuImage.setFilter( GPUImageSepiaFilter ())
// Later when image should be saved saved:
gpuImage.saveToPictures( " GPUImage " , " ImageWithFilter.jpg " , null )
}
< jp .co.cyberagent.android.gpuimage.GPUImageView
android : id = " @+id/gpuimageview "
android : layout_width = " match_parent "
android : layout_height = " match_parent "
app : gpuimage_show_loading = " false "
app : gpuimage_surface_type = " texture_view " /> <!-- surface_view or texture_view -->
ジャバ:
@ Override
public void onCreate ( final Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState );
setContentView ( R . layout . activity );
Uri imageUri = ...;
gpuImageView = findViewById ( R . id . gpuimageview );
gpuImageView . setImage ( imageUri ); // this loads image on the current thread, should be run in a thread
gpuImageView . setFilter ( new GPUImageSepiaFilter ());
// Later when image should be saved saved:
gpuImageView . saveToPictures ( "GPUImage" , "ImageWithFilter.jpg" , null );
}
コトリン:
public override fun onCreate ( savedInstanceState : Bundle ? ) {
super .onCreate(savedInstanceState)
setContentView( R .layout.activity_gallery)
val imageUri : Uri = .. .
gpuImageView = findViewById< GPUImageView >( R .id.gpuimageview)
gpuImageView.setImage(imageUri) // this loads image on the current thread, should be run in a thread
gpuImageView.setFilter( GPUImageSepiaFilter ())
// Later when image should be saved saved:
gpuImageView.saveToPictures( " GPUImage " , " ImageWithFilter.jpg " , null )
}
ジャバ:
public void onCreate ( final Bundle savedInstanceState ) {
public void onCreate ( final Bundle savedInstanceState ) {
Uri imageUri = ...;
gpuImage = new GPUImage ( context );
gpuImage . setFilter ( new GPUImageSobelEdgeDetection ());
gpuImage . setImage ( imageUri );
gpuImage . saveToPictures ( "GPUImage" , "ImageWithFilter.jpg" , null );
}
コトリン:
public override fun onCreate ( savedInstanceState : Bundle ? ) {
super .onCreate(savedInstanceState)
setContentView( R .layout.activity_gallery)
val imageUri : Uri = .. .
gpuImage = GPUImage ( this )
gpuImage.setFilter( GPUImageSepiaFilter ())
gpuImage.setImage(imageUri)
gpuImage.saveToPictures( " GPUImage " , " ImageWithFilter.jpg " , null )
}
Maven を使用する場合は、必ずクリーンなターゲットを実行してください。
gradle clean assemble
Copyright 2018 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.