Skip to content

Commit

Permalink
update 0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoang Lam committed Sep 19, 2023
1 parent 3f8399b commit 95e8e56
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ DropShadow_minSdkVersion=21
DropShadow_targetSdkVersion=31
DropShadow_compileSdkVersion=31
DropShadow_ndkversion=21.4.7075529
android.useAndroidX=true
23 changes: 19 additions & 4 deletions android/src/main/java/com/dropShadow/DropShadowLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.views.view.ReactViewGroup;

public class DropShadowLayout extends ReactViewGroup {
public class DropShadowLayout extends ReactViewGroup {
public DropShadowLayout(Context context) {
super(context);
}
Expand Down Expand Up @@ -115,7 +115,7 @@ protected void onMeasure(int widthSpec, int heightSpec) {
content.recycle();
hasContent = false;
content = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
draw.setBitmap(content);
draw.setBitmap(to4BytesPerPixelBitmap(content));
}
invalidate();
}
Expand All @@ -137,11 +137,26 @@ public void dispatchDraw(Canvas canvas) {
}
x = dX - ((shadow.getWidth() - content.getWidth()) / 2);
y = dY - ((shadow.getHeight() - content.getHeight()) / 2);
canvas.drawBitmap(shadow, x, y, paint);
canvas.drawBitmap(to4BytesPerPixelBitmap(shadow), x, y, paint);
}
canvas.drawBitmap(content, 0f, 0f, null);
canvas.drawBitmap(to4BytesPerPixelBitmap(content), 0f, 0f, null);
}
super.dispatchDraw(canvas);
}

/**
* Convert a Bitmap to a Bitmap that has 4 bytes per pixel
*
* @param input The bitmap to convert to a 4 bytes per pixel Bitmap
* @return The converted Bitmap. Note: The caller of this method is
* responsible for reycling the input
*/
public static Bitmap to4BytesPerPixelBitmap(@NonNull final Bitmap input) {
final Bitmap bitmap = Bitmap.createBitmap(input.getWidth(), input.getHeight(), Bitmap.Config.ARGB_8888);
// Instantiate the canvas to draw on:
final Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(input, 0, 0, null);
// Return the new bitmap:
return bitmap;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-drop-shadow",
"version": "0.0.8",
"version": "0.0.9",
"description": "is a small and simple package that helps make your React Native app",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down

0 comments on commit 95e8e56

Please sign in to comment.