Coder Social home page Coder Social logo

steelkiwi / cropiwa Goto Github PK

View Code? Open in Web Editor NEW
2.2K 50.0 330.0 7.88 MB

📐 Configurable Custom Crop widget for Android

Home Page: http://steelkiwi.com/

Java 100.00%
crop crop-image cropper android java image-cropper image photo photo-editing animation

cropiwa's Introduction

CropIwa

Made in SteelKiwi Android Arsenal

The library is a highly configurable widget for image cropping.

GifSample1

Gradle

Add this into your dependencies block.

compile 'com.steelkiwi:cropiwa:1.0.3'

Sample

Please see the sample app for library usage examples.

Wiki

The library has a modular architecture, which makes it highly configurable. For info on how to configure CropIwaView refer to the sections below.

One of the useful features is that you don't have to wait for a result - after crop request is done, simply switch to another screen and wait for the result in a form of broadcast.

Usage:

Add CropIwa to your xml:

<com.steelkiwi.cropiwa.CropIwaView
  android:id="@+id/crop_view"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />

Image saving

cropView.crop(new CropIwaSaveConfig.Builder(destinationUri)
  .setCompressFormat(Bitmap.CompressFormat.PNG)
  .setSize(outWidth, outHeight) //Optional. If not specified, SRC dimensions will be used
  .setQuality(100) //Hint for lossy compression formats
  .build());

Callbacks

Cropped region saved callback. When crop request completes, a broadcast is sent. You can either listen to it using the CropIwaView intance

cropView.setCropSaveCompleteListener(bitmapUri -> {
  //Do something
});

cropView.setErrorListener(error -> {
  //Do something
});

or work directly with a broadcast receiver. The advantage is that it can be used from any part of the app, where you have an access to Context.

CropIwaResultReceiver resultReceiver = new CropIwaResultReceiver();
resultReceiver.setListener(resultListener);
resultReceiver.register(context);

//Don't forget to unregister it when you are done
resultReceiver.unregister(context);

You can subscribe for changes in CropIwaViews configs. Listeners will be notified anytime .apply() is called.

cropIwaView.configureOverlay().addConfigChangeListener(listener);
cropIwaView.configureImage().addConfigChangeListener(listener)

Basic View Configuration

  • Enable user to resize a crop area. Default is true.
app:ci_dynamic_aspect_ratio="true|false"

cropView.configureOverlay()
  .setDynamicCrop(enabled)
  .apply();
  • Draw a 3x3 grid. Default is true.
app:ci_draw_grid="true|false"

cropView.configureOverlay()
  .setShouldDrawGrid(draw)
  .apply();
  • Set an initial crop area's aspect ratio.
app:ci_aspect_ratio_w="16"
app:ci_aspect_ratio_h="9"

cropView.configureOverlay()
  .setAspectRatio(new AspectRatio(16, 9))
  .setAspectRatio(AspectRatio.IMG_SRC) //If you want crop area to be equal to the dimensions of an image
  .apply();
  • Initial image position. Behavior is similar to ImageView's scaleType.
app:ci_initial_position="centerCrop|centerInside"

cropView.configureImage()
  .setImageInitialPosition(position)
  .apply();
  • Set current scale of the image.
//Value is a float from 0.01f to 1
cropIwaView.configureImage()
  .setScale(scale)
  .apply();
  • Enable pinch gesture to scale an image.
app:ci_scale_enabled="true|false"

cropView.configureImage()
  .setImageScaleEnabled(enabled)
  .apply();
  • Enable finger drag to translate an image.
app:ci_translation_enabled="true|false"

cropView.configureImage()
  .setImageTranslationEnabled(enabled)
  .apply();
  • Choosing from default crop area shapes. Default is rectangle.
app:ci_crop_shape="rectangle|oval"

cropView.configureOverlay()
  .setCropShape(new CropIwaRectShape(cropView.configureOverlay()))
  .setCropShape(new CropIwaOvalShape(cropView.configureOverlay()))
  .apply();
  • You can set a min-max scale. Default min is 0.7, default max is 3.
app:ci_max_scale="1f"

cropView.configureImage()
  .setMinScale(minScale)
  .setMaxScale(maxScale)
  .apply();
  • Crop area min size.
app:ci_min_crop_width="40dp"
app:ci_min_crop_height="40dp"

cropView.configureOverlay()
  .setMinWidth(dps)
  .setMinHeight(dps)
  .apply();
  • Dimensions.
app:ci_border_width="1dp"
app:ci_corner_width="1dp"
app:ci_grid_width="1dp"

cropView.configureOverlay()
  .setBorderStrokeWidth(dps)
  .setCornerStrokeWidth(dps)
  .setGridStrokeWidth(dps)
  .apply();
  • Colors.
app:ci_border_color="#fff"
app:ci_corner_color="#fff"
app:ci_grid_color="#fff"
app:ci_overlay_color="#fff"

cropView.configureOverlay()
  .setBorderColor(Color.WHITE)
  .setCornerColor(Color.WHITE)
  .setGridColor(Color.WHITE)
  .setOverlayColor(Color.WHITE)
  .apply();

Advanced View Configuration

You can work directly with Paint objects. This gives you an ability, for example, to draw a grid with dashed effect.

Paint gridPaint = cropView.configureOverlay()
  .getCropShape()
  .getGridPaint();
gridPaint.setPathEffect(new DashPathEffect(new float[] {interval, interval}, 0));

You can obtain other Paints in the same way.

CropIwaOverlayConfig config = cropView.configureOverlay();
CropIwaShape shape = config.getCropShape();
shape.getGridPaint();
shape.getBorderPaint();
shape.getCornerPaint();

You can also create custom crop area shapes. Just extend CropIwaShape (for an example refer to CropIwaOvalShape) and set an instance of you class using:

cropView.configureOverlay()
  .setCropShape(new MyAwesomeShape())
  .apply();

License

Copyright © 2017 SteelKiwi, http://steelkiwi.com

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.

cropiwa's People

Contributors

polyak01 avatar sdoward avatar vellrya avatar yarolegovich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cropiwa's Issues

StrictMode: Explicit termination method 'close' not called

Hi,

Thanks for this wonderfull crop library !

When I enable the strict mode on my application :

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectDiskReads()
                .detectDiskWrites()
                .detectNetwork()
                .penaltyLog()
                .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()
                .penaltyLog()
                .build());

I optain one strict mode error when load the uri of device camera picture.

D/CropIwaLog: LoadBitmapCommand for file:///storage/emulated/0/Android/data/xxxxx/files/photo.jpg delayed, wrong dimensions {width=0, height=0}
I/Choreographer: Skipped 2263 frames!  The application may be doing too much work on its main thread.
D/CropIwaLog: load bitmap request for {file:///storage/emulated/0/Android/data/xxxxx/files/photo.jpg}
E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
                       java.lang.Throwable: Explicit termination method 'close' not called
					       at dalvik.system.CloseGuard.open(CloseGuard.java:180)
                           at java.io.FileInputStream.<init>(FileInputStream.java:78)
                           at java.io.FileInputStream.<init>(FileInputStream.java:103)
                           at android.content.ContentResolver.openInputStream(ContentResolver.java:660)
                           at com.steelkiwi.cropiwa.image.CropIwaBitmapManager.getOptimalSizeOptions(CropIwaBitmapManager.java:197)
                           at com.steelkiwi.cropiwa.image.CropIwaBitmapManager.getBitmapFactoryOptions(CropIwaBitmapManager.java:186)
                           at com.steelkiwi.cropiwa.image.CropIwaBitmapManager.loadToMemory(CropIwaBitmapManager.java:118)
                           at com.steelkiwi.cropiwa.image.LoadImageTask.doInBackground(LoadImageTask.java:31)
                           at com.steelkiwi.cropiwa.image.LoadImageTask.doInBackground(LoadImageTask.java:12)
                           at android.os.AsyncTask$2.call(AsyncTask.java:295)
                           at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                           at java.lang.Thread.run(Thread.java:818)
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb83e10b0
D/CropIwaLog: loaded image with dimensions {width=1080, height=1920}
D/CropIwaLog: {file:///storage/emulated/0/Android/data/xxxx/files/photo.jpg} loading completed, listener got the result

I use CropIWA version 1.0.0

Thanks

Christophe.

Fatal Exception if cropping while holding image out of bounds

I've noticed an issue (fringe case honestly) when cropping an image while holding it out of the canvas's bounds : Screenshot here
Here's the error I get :

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3 Process: myApp, PID: 14146 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:318) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762) Caused by: java.lang.IllegalArgumentException: y must be >= 0 at android.graphics.Bitmap.checkXYSign(Bitmap.java:423) at android.graphics.Bitmap.createBitmap(Bitmap.java:823) at android.graphics.Bitmap.createBitmap(Bitmap.java:793) at com.steelkiwi.cropiwa.image.CropArea.applyCropTo(CropArea.java:35) at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:49) at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:20) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  at java.lang.Thread.run(Thread.java:762) 

I haven't created a pull request to fix the problem because I don't know which solution you prefer, maybe just trigger the ErrorListener ?
Thanks :)

Сохранение без поворота

Здравствуйте. Есть такой вопрос: если повернуть картинку во время обрезания, то при сохранении картинка повернута не будет. Насколько я понимаю, мы картинку и не поворачиваем, а поворачиваем CropiwaView. Есть ли удобный способ сохранения картинки с поворотом?

Warning: CropIwaOvalShape: can't find referenced method 'int save(int)'

Warning: com.steelkiwi.cropiwa.shape.CropIwaOvalShape: can't find referenced method 'int save(int)' in library class android.graphics.Canvas

A class com.steelkiwi.cropiwa.shape.CropIwaOvalShape, error on 45 line:

canvas.save(Canvas.CLIP_SAVE_FLAG);

CLIP_SAVE_FLAG - cannot resolve symbol

CLIP_SAVE_FLAG has been pruned in P, along with the parametarized save() method.
Source: https://developer.android.com/sdk/api_diff/28/changes/android.graphics.Canvas

As a workaround (proguard):

-dontwarn com.steelkiwi.**
-keep class com.steelkiwi.**
-keep interface com.steelkiwi.**

crop size more than screen width

Error occurs on https://www.gsmarena.com/oneplus_5t-8912.php
cropiwa settings:

app:ci_aspect_ratio_h="4"
app:ci_aspect_ratio_w="3"
app:ci_border_color="@color/colorAccentGreen"
app:ci_border_width="4dp"
app:ci_crop_scale="0.75"
app:ci_crop_shape="rectangle"
app:ci_draw_grid="false"
app:ci_dynamic_aspect_ratio="false"
app:ci_scale_enabled="true"
app:ci_translation_enabled="true"

Problem in method CropiwaOverlayView>setCropRectAccordingToAspectRatio()

 boolean calculateFromWidth =
                aspectRatio.getHeight() < aspectRatio.getWidth()
                        || (aspectRatio.isSquare() && viewWidth < viewHeight);

        if (calculateFromWidth) {
            halfWidth = viewWidth * cropScale * 0.5f;
            halfHeight = halfWidth / aspectRatio.getRatio();
        } else {
            halfHeight = viewHeight * cropScale * 0.5f;
            halfWidth = halfHeight * aspectRatio.getRatio();
        }

        cropRect.set(
                centerX - halfWidth, centerY - halfHeight,
                centerX + halfWidth, centerY + halfHeight);

calculate as 2160×0.75×3/4 = 1215. This is more than 1080 width this phone (screen ratio 18:9)

setSize is not working

while cropping image I use setSize to crop in some size say 512x512. but it still store in 600x600 or 524x524.

Crash CropImageTask.com.steelkiwi.cropiwa.image.CropArea.applyCropTo

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
Caused by java.lang.IllegalArgumentException: unknown bitmap configuration
at android.graphics.Bitmap.nativeCreate(Bitmap.java)
at android.graphics.Bitmap.createBitmap(Bitmap.java:977)
at android.graphics.Bitmap.createBitmap(Bitmap.java:948)
at android.graphics.Bitmap.createBitmap(Bitmap.java:868)
at android.graphics.Bitmap.createBitmap(Bitmap.java:793)
at com.steelkiwi.cropiwa.image.CropImageTask.com.steelkiwi.cropiwa.image.CropArea.applyCropTo(SourceFile:2035)
at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(SourceFile:20)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)

#0. Crashed: AsyncTask #5: 0 0 0x0000000000000000
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)

#1. OkHttp ConnectionPool
at java.lang.Object.wait(Object.java)
at com.android.okhttp.ConnectionPool.performCleanup(ConnectionPool.java:319)
at com.android.okhttp.ConnectionPool.runCleanupUntilPoolIsEmpty(ConnectionPool.java:256)
at com.android.okhttp.ConnectionPool.-wrap0(ConnectionPool.java)
at com.android.okhttp.ConnectionPool$1.run(ConnectionPool.java:102)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)

Get Black sreen after I save image and dispay on content Page in xamarin.

After selecting the image from a gallery, I have shown into CropIwaView, and when I saved image OnCroppedRegionSaved() method which done cropping logic for me is called and after that, I redirect to a content page, in between redirection I saw a black screen which last long more than 10-15 seconds, and time is increasing as I do more operations on images, how can we avoid the black screen between redirations

set output dimensions in px

I want to crop an image to a fixed dimension. the .setSize() function doesn't seem to work. I also tried converting px to dp but no luck, output size still is random.

Bitmap dimensions exceeded max android texture size

Different android devices have various max texture dimension.

On some configurations when bitmap dimension exceeded this limit no image is displayed.

For example my Smaung galaxy S5 has max texture size: 4096 px
Full screen CropImageView has dimensions: 1080x1848 px
Image file is: 5312x2988 px

As result loaded bitmap has size 5312x2988 px, width is larger than max texture size and no image is displayed.

Increasing inSmapleSize when loading bitmap to met max texture requiremnts should fix this issue.
I will provide pull request.

Zoom out issue

Hello,

Your library is an awesome one for circular crop. But i have faced an issue in the images which had been taken from very near. I m not able to zoom out much & also there is no scaletype option like imageview.

Please fix this issue if possible

Center the crop window in the frame

How to center the crop window in the crop layout? I am using square layout with aspect ratio 1:1 for crop window. But the crop window is not center align with respect to the layout. How to achieve this?

Need image in specific resolution without stretch

First of all thank you for making such nice library. I have decided to use that in my current project.
I have 1 issue that if I want to save image size in for example 512x512 then how to do without stretch. If I give setSize(512,512) method but it still store in 176x176 or 187x187 that type of resolution.

When attempting to run sample, following error occurs.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.app.Application.getFilesDir()' on a null object referenceat com...sample.f.a.b(SourceFile:35)at com...sample.CropGalleryActivity.onCreate(SourceFile:40)
This is typically this line:
cropGalleryAdapter.addImages(CropGallery.getCroppedImageUris());
Any suggestions:

Next Release

I would love to get my hands on the changes in #25

Do you have a release schedule?

crop some gif picture crash

the bellow picture always crash

786c66a35feff245bc6b1278b8d50e5b

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #7
                                                                      Process: com.yitantech.gaigai, PID: 31754
                                                                      java.lang.RuntimeException: An error occured while executing doInBackground()
                                                                          at android.os.AsyncTask$3.done(AsyncTask.java:304)
                                                                          at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                                                                          at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                                                                          at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                                                                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                          at java.lang.Thread.run(Thread.java:818)
                                                                       Caused by: java.lang.NullPointerException: Attempt to read from field 'int android.graphics.Bitmap$Config.nativeInt' on a null object reference
                                                                          at android.graphics.Bitmap.copy(Bitmap.java:569)
                                                                          at com.steelkiwi.cropiwa.image.CropArea.applyCropTo(CropArea.java:40)
                                                                          at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:49)
                                                                          at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:20)
                                                                          at android.os.AsyncTask$2.call(AsyncTask.java:292)
                                                                          at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
                                                                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                                                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                                                          at java.lang.Thread.run(Thread.java:818) 
02-09 17:27:54.930 32618-32618/com.yitantech.gaigai E/ActivityThread: Failed to find provider info for com.tinker.debug.debugprovider

Performance Improvements

First thanks for the library it's been a big help for the project I am working on.

I can see some opportunities to make the lib faster. The bottle necks are the moment (unsurprisingly) are reading and writing to disk.

Testing with the GT-i9515 the read takes between 600ms - 1200ms. An obvious way to resolve this would be to hold the original Bitmap in memory. This would remove this bottle neck completely. Is there some reason for not doing this originally?

As for writing, some clients might not need CropIwa to write to disk.
My use case is that I merge the cropped image with another image before I write to disk. So the flow at the moment is..

  • setUri()
    • CropIwaread
  • Crop file
    • CropIwa read and write
  • Merge file
    • Client read and write

If CropIwa was able to pass back the cropped bitmap I would see huge performance improvements.

Would it be feasible to provide 2 Callback listeners? 1 for the Uri and 1 for the Bitmap?

I am happy to contribute if you think either of these are good directions to take.

setImage() does not work

Hi,

If i use setImageUri() it works perfectly, but if i convert same uri to Bitmap and set using setImage(bitmap), it didn't load bitmap.

Thanks

OOM Error

На многих устройствах при попытке выделить большУю часть изображения приложение падает:

Caused by: java.lang.OutOfMemoryError

                                                                     at android.graphics.Bitmap.nativeCreate(Native Method)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:640)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:575)
                                                                     at android.graphics.Bitmap.createBitmap(Bitmap.java:501)
                                                                     at com.steelkiwi.cropiwa.image.CropArea.applyCropTo(CropArea.java:35)
                                                                     at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:49)
                                                                     at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:20)
                                                                     at android.os.AsyncTask$2.call(AsyncTask.java:287)
                                                                     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                                                                     at java.util.concurrent.FutureTask.run(FutureTask.java:137) 
                                                                     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 
                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 
                                                                     at java.lang.Thread.run(Thread.java:856) 

Хотелось бы исправления)

How to make crop shape without margin

We are developing a profile section for an app that requires us to draw a crop overlay shape (rect and oval) that has a width equal to the whole screen. We have tried different approaches but we always end up with a slight margin on the sides of the oval and the rectangle. What should we do to achieve our goal? What kind of ShapeMask should we develop?

Thanks!

Init with initial position

Is there a way to initialize the view with a preset of scale and position?

I'd like to be able to adjust an image (scale and position it), then save this "state", and then when I open the image for cropping again, I can continue from the same point I left it.

Can you set me in the right direction for implementing this?
Which parts of the CropView, CropImageView, or whatever, should I save for later use, and then how can I load it with those settings again?

Problem when no external storage is available

Hi, got the following :
java.io.FileNotFoundException: /temp_700_1511308260364: open failed: EROFS (Read-only file system)
...
at com.steelkiwi.cropiwa.image.CropIwaBitmapManager.cacheLocally(CropIwaBitmapManager.java:171)

Appear to come from the line :
File local = new File(context.getExternalCacheDir(), generateLocalTempFileName(input));

Occurs when no external storage is available ... (Nexus 4 ... )
W

issue importing

I get this:

Unable to load class 'org.gradle.api.internal.component.Usage'. Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

image

crash with cropiwa while cropping image

stacktrace as follows:

java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:760)
java.lang.IllegalArgumentException: x must be >= 0
at android.graphics.Bitmap.checkXYSign(Bitmap.java:406
at android.graphics.Bitmap.createBitmap(Bitmap.java:742)
at android.graphics.Bitmap.createBitmap(Bitmap.java:712)
at com.android.maya.business.shoot.cropiwa.image.CropArea.create(CropArea.java)
moveRectToCoordinateSystem(CropArea.java)
applyCropTo(CropArea.java)
findRealCoordinate(CropArea.java)
at com.android.maya.business.shoot.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java)
onPostExecute(CropImageTask.java)
at com.android.maya.business.shoot.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 morejava.lang.IllegalArgumentException: x must be >= 0
at android.graphics.Bitmap.checkXYSign(Bitmap.java:406)
at android.graphics.Bitmap.createBitmap(Bitmap.java:742)
at android.graphics.Bitmap.createBitmap(Bitmap.java:712)
at com.android.maya.business.shoot.cropiwa.image.CropArea.create(CropArea.java)
moveRectToCoordinateSystem(CropArea.java)
applyCropTo(CropArea.java)
findRealCoordinate(CropArea.java)
at com.android.maya.business.shoot.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java)
onPostExecute(CropImageTask.java)
at com.android.maya.business.shoot.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:760)

Crash when the Uri has "content://" scheme

val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.type = "image/*"
startActivityForResult(Intent.createChooser(intent, "Pick a photo"), 777)

uri = content://com.android.providers.media.documents/document/image%3A146630

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.getScheme()' on a null object reference
        at com.steelkiwi.cropiwa.image.CropIwaBitmapManager.isWebUri(CropIwaBitmapManager.java:285)
        at com.steelkiwi.cropiwa.image.CropIwaBitmapManager.toLocalUri(CropIwaBitmapManager.java:150)
        at com.steelkiwi.cropiwa.image.CropIwaBitmapManager.loadToMemory(CropIwaBitmapManager.java:117)
        at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:41)
        at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:20)

what is use of setMinScale and setMaxScale?

what is use of setMinScale and setMaxScale?
because if I user setMinScale(0.3f) and setMaxScale(1) it works fine.
but if I use setMinScale(0.7f) and setMaxScale(1) , then full image is not scaling into crop area,

x/y must be >= 0

FATAL EXCEPTION: AsyncTask #3
                                                                        java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                            at android.os.AsyncTask$3.done(AsyncTask.java:325)
                                                                            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                            at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
                                                                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                            at java.lang.Thread.run(Thread.java:761)
                                                                         Caused by: java.lang.IllegalArgumentException: x must be >= 0
                                                                            at android.graphics.Bitmap.checkXYSign(Bitmap.java:395)
                                                                            at android.graphics.Bitmap.createBitmap(Bitmap.java:731)
                                                                            at android.graphics.Bitmap.createBitmap(Bitmap.java:701)
                                                                            at com.steelkiwi.cropiwa.image.CropArea.applyCropTo(CropArea.java:35)
                                                                            at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:49)
                                                                            at com.steelkiwi.cropiwa.image.CropImageTask.doInBackground(CropImageTask.java:20)
                                                                            at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
                                                                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
                                                                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
                                                                            at java.lang.Thread.run(Thread.java:761) 

I have no way to catch this error :(
Can this be solved by catching the IllegalArgumentException in the AsyncTask, return it and call the onError method?

remove lower section

Hello there,

how is it possible to hide crop mode and others and force user to crop based pre defined settings. so user does not have to select crop mode (hide it).

Zoom issues

The zoom only works in some instances.

This is the current setup I use:

<com.steelkiwi.cropiwa.CropIwaView
      android:id="@+id/crop_image_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:ci_dynamic_aspect_ratio="false"
      app:ci_draw_grid="false"
      app:ci_scale_enabled="true"
      app:ci_translation_enabled="true"
      app:ci_crop_shape="oval"
      app:ci_border_width="1dp"
      app:ci_border_color="#FFFFFF"
      app:ci_max_scale="100"
      app:ci_overlay_color="#66000000" />

Did I miss something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.