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을 사용할 때는 clean 대상을 실행해야 합니다.
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.