android gpuimage
1.0.0
فكرة من: إطار عمل iOS GPUImage
الهدف هو الحصول على شيء مشابه لـ GPUImage قدر الإمكان. تظليل Vertex و Fragment متماثلان تمامًا. وبهذه الطريقة، يصبح من السهل نقل المرشحات من 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.