android gpuimage
1.0.0
Идея из: iOS GPUImage framework.
Цель состоит в том, чтобы сделать что-то как можно более похожее на 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.