cesards / superimageview Goto Github PK
View Code? Open in Web Editor NEWCrop and Rounded Corners added to an ImageView.
License: MIT License
Crop and Rounded Corners added to an ImageView.
License: MIT License
[BUG]
尊敬的开发者你好:
add a condition in order to avoid null pointers whenever we don't have an image set.
final Drawable image = getDrawable();
if (cropType != CropType.NONE && viewHeight > 0 && viewWidth > 0 && image != null) {
final Matrix matrix = imageMaths.getMatrix();
final int drawableWidth = image.getIntrinsicWidth();
final int drawableHeight = image.getIntrinsicHeight();
according to mvn-central your last build is from oct. 2015 but your last comit in this repo is a month ago...so plz update your mvn-central
NullPointerException in line: int drawableWidth = getDrawable().getIntrinsicWidth(); if image not set
I tried using the library in xml according to the example and the image does not get cropped, it just shows the full image. I want the image to be cropped at the bottom. I tried any of the options, without any affect. How do I make it work in xml?
Please check if the current library supports elevation of the view. Thanks.
Have a look to this: https://github.com/diego-gomez-olvera/RtlViewPager
Is there anything XML attributes? sometimes when scrolling up Crop Type disappears
The current minsdk is 14, but the project can compile against a minor api version.
[BUG]
尊敬的开发者你好:
Bug
1、 ImageCroppingActivity中Left Top crop of the horizontal image、Left Center crop of the horizontal image、Left Top crop of the horizontal image,发现三种裁剪和显示方式都是一样的。没有任何区别。
2、Right Top crop of the horizontal image、Right Center crop of the horizontal image、Right Top crop of the horizontal image三种裁剪和显示方式都是一样的,没有任何区别。
3、请检查是否裁剪算法错误。未实现标注的裁剪和显示方式
com.codeforvictory.android.superimageview.crop.ImageTransformation
void compute(@CropType int cropType) {
int viewWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
int viewHeight = view.getHeight() - view.getPaddingTop() - view.getPaddingBottom();
if (cropType != CropType.NONE && viewHeight > 0 && viewWidth > 0) {
Matrix matrix = compatMatrix.matrix(cropType);
Drawable drawable = view.getDrawable();
int drawableWidth = drawable.getIntrinsicWidth();
int drawableHeight = drawable.getIntrinsicHeight();
float scaleY = (float) viewHeight / (float) drawableHeight;
float scaleX = (float) viewWidth / (float) drawableWidth;
float scale = scaleX > scaleY ? scaleX : scaleY;
matrix.setScale(scale, scale); // Same as doing matrix.reset() and matrix.preScale(...)
boolean verticalImageMode = scaleX > scaleY;
float xTranslation = getXTranslation(
cropType,
viewWidth,
drawableWidth * scale,
verticalImageMode
);
float yTranslation = getYTranslation(
cropType,
viewHeight,
drawableHeight * scale,
verticalImageMode
);
matrix.postTranslate(xTranslation, yTranslation);
view.setImageMatrix(matrix);
}
}
Adding the dependency compile 'com.cesards.android:cropimageview:1.0.2.1'
to build.gradle(Module: app) causes RuntimeException. The App works fine on removing the dependency. Adding it again causes the app to crash as soon as it launches.
I tried reproducing it three times and it occurred all the three times.
I came here because of
https://gist.github.com/arriolac/3843346#gistcomment-1395269
I just want a TopCropImageView.
The documentation suggests a "custom" namespace in xml such as
custom:crop="centerTop"
but the samples use really ugly app namespace with class references such as
app:siv_cropImplementation="com.codeforvictory.android.superimageview.crop.CroppedImage"
Anyway, none of it is working out of the box. I think you need to clean up this library and documentation for it to be useful.
Currently we can choose to scale-crop from center (center crop) , from top, and other sides...
But what should I do to make it work for 20% from the top?
And what should be done to make it work for videos too?
I've asked about this here:
https://stackoverflow.com/questions/54216273/how-to-have-similar-mechanism-of-center-crop-on-exoplayers-playerview-but-not/
Please, if you know how to do it, publish an answer. I will gladly grant the bounty if it works.
at com.cesards.cropimageview.CropImageView.computeImageMatrix(CropImageView.java:119)
causes crash if src is not specified in xml. So using an Image loading library does not work.
would suggest to add a null-check for the drawable
jcenter is shutting down on May 1
https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
Any chance this artifact can be uploaded to Maven Central before then?
This should supersede #28 due to the shutdown.
Provide the ability to round corners in the image view
Add KenbBurnsView support to the library, like this library does
Image is not being cropped correctly in API < 18
This is Hugo related issue. Once it gets fixed, I will do the corresponding changes here! :-)
Tested on Pixel 2 with Android P.
The crash log:
2018-10-25 02:22:36.168 19882-19882/com.codeforvictory.android.superimageview.samples E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.codeforvictory.android.superimageview.samples, PID: 19882
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.codeforvictory.android.superimageview.SuperImageView
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.codeforvictory.android.superimageview.SuperImageView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.codeforvictory.superimageview.samples.superimageview.rounded_corners.ImagesRecyclerAdapter.onCreateViewHolder(ImagesRecyclerAdapter.java:27)
at com.codeforvictory.superimageview.samples.superimageview.rounded_corners.ImagesRecyclerAdapter.onCreateViewHolder(ImagesRecyclerAdapter.java:15)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:753)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2793)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2320)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
2018-10-25 02:22:36.169 19882-19882/com.codeforvictory.android.superimageview.samples E/AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7184)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: This can't be possible
at com.codeforvictory.android.superimageview.roundedcorners.RoundedCornersImage.setup(RoundedCornersImage.java:115)
at com.codeforvictory.android.superimageview.SuperImageView.setupRoundedCorners(SuperImageView.java:252)
at com.codeforvictory.android.superimageview.SuperImageView.setup(SuperImageView.java:99)
at com.codeforvictory.android.superimageview.SuperImageView.(SuperImageView.java:34)
... 60 more
It seems to me that the cropImageView don't rescale the image to respect the ScaleType.
For example i'm using the CropImageView with a CENTER_CROP ScaleType. It works when opening the image but when a rotation (here I only tested with +-90°) is applied using CropImageView.rotateImage the image keep its size which is correct according to the initialization but not correct with respect to the rotation.
XML-Code:
<com.codeforvictory.android.superimageview.SuperImageView xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/result"
android:layout_gravity="bottom"
android:layout_marginEnd="383dp"
android:layout_marginRight="383dp"
android:paddingBottom="10dp" custom:crop="topLeft|centerLeft|bottomLeft|topRight|centerRight|bottomRight|centerTop|centerBottom"
custom:layout_constraintEnd_toEndOf="parent" />
Stacktrace:
Android resource linking failed
Output: C:\projects**\app\src\main\res\layout\review_image.xml:28: error: 'topLeft|centerLeft|bottomLeft|topRight|centerRight|bottomRight|centerTop|centerBottom' is incompatible with attribute crop (attr) enum [bottomLeft=2, bottomRight=5, centerBottom=7, centerLeft=1, centerRight=4, centerTop=6, topLeft=0, topRight=3] [weak].
error: failed linking file resources.
Command: C:\Users*.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\80d2698f32793bc1c91ad5fc69b2dc3a\aapt2-3.2.1-4818971-windows\aapt2.exe link -I
C:\Android\sdk\platforms\android-28\android.jar
--manifest
C:\projects*\app\build\intermediates\split-apk\debug\resources\AndroidManifest.xml
-o
C:\projects*\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_
-R
@C:\projects*\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt
--auto-add-overlay
--java
C:\projects*\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r
--custom-package
de.geocv..
-0
apk
--preferred-density
xhdpi
--output-text-symbols
C:\projects*\app\build\intermediates\symbols\debug\R.txt
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
<com.cesards.cropimageview.CropImageView
android:id="@+id/iv_profile_pic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/gradient_bottom_top"
android:src="@drawable/add_profile_picbkg"
app:crop="centerTop"
/>
This is what I get when I start activity:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.drawable.Drawable.getIntrinsicWidth()' on a null object reference
at com.cesards.cropimageview.CropImageView.computeImageMatrix(CropImageView.java:119)
at com.cesards.cropimageview.CropImageView.setFrame(CropImageView.java:107)
at android.view.View.layout(View.java:16648)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
at android.view.View.layout(View.java:16651)
at android.view.ViewGroup.layout(ViewGroup.java:5440)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2183)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1943)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1119)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6060)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
I use Picasso to load my images but I need to use this library to correctly center my images but because this library extends FrameLayout and its imageView is private, I'm not able to use it. Any ways around this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.