How To Resize Image Using OpenCV
To Resize Image Using OpenCV Follow The Following Steps.
Step1. In The View Area Add ImageView Or Any Other Image Displaying View.
Step2. Make Sure You Select OpenCV Android SDK In The Library Manager.
Step3. In The Custom Imports Add The Following Classes From OpenCV.
Step4. Load OpenCV C++ Binary Using The Following Code.
Step5. In Any Event You Want(OnCreate, OnButton Click Or Any Other Event) Where You Want To Resize The Image Use This Code. Read Comment's For Better Understanding.
To Resize Image Using OpenCV Follow The Following Steps.
Step1. In The View Area Add ImageView Or Any Other Image Displaying View.
Step2. Make Sure You Select OpenCV Android SDK In The Library Manager.
Step3. In The Custom Imports Add The Following Classes From OpenCV.
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.android.Utils;
import android.graphics.Bitmap;
import org.opencv.imgproc.Imgproc;
import org.opencv.imgcodecs.Imgcodecs;
import android.graphics.drawable.BitmapDrawable;
Step4. Load OpenCV C++ Binary Using The Following Code.
}
static {
System.loadLibrary("opencv_java4");
}
{
Step5. In Any Event You Want(OnCreate, OnButton Click Or Any Other Event) Where You Want To Resize The Image Use This Code. Read Comment's For Better Understanding.
//Get Bitmap From ImageView Called imageview1
Bitmap bitmap = ((BitmapDrawable) imageview1.getDrawable()).getBitmap();
//Initialize Mat Object For The Bitmap
Mat mat = new Mat();
//Convert The Bitmap From imageview1 To OpenCV Mat Object.
Utils.bitmapToMat(bitmap, mat);
//Initialize Mat Object For The Resized Image
Mat resizedmat = new Mat();
//Resize The Image From Mat Object With New Width 512 & Height 512
Imgproc.resize(mat, resizedmat, new Size(seekbar1.getProgress(), seekbar1.getProgress()));
//Create Bitmap From The Resized Mat Object Columns & Rows.
Bitmap resizedbitmap = Bitmap.createBitmap(resizedmat.cols(), resizedmat.rows(), Bitmap.Config.ARGB_8888);
//Convert The Resized Mat Object To Bitmap
Utils.matToBitmap(resizedmat, resizedbitmap);
//Display The Resized Bitmap In imageview1
imageview1.setImageBitmap(resizedbitmap);
//Release The Mat Objects To Prevent Memory Leaks
mat.release();
resizedmat.release();
Android Developers YouTube Channel Reaches 40 Subscribers.
๐ Thank You ๐
@SE_BIBEL_MEK
๐ @androiddevstutorial
๐ Thank You ๐
@SE_BIBEL_MEK
๐ @androiddevstutorial
๐2
โ ๏ธ Caution โ ๏ธ
I've Tested This Sketchware Pro Nightly Build On realme RMX3381 Android13 Device & I Have Not Found Any Bugs(Except The Local Library Downloader Bug). But There May Be Some Unstablity Issues In Other Android Versions. So I Highly Recommend You To Backup Your .sketchware Folder Before Trying This One. If You Want The Latest Stable Build Of Sketchware Pro You Can Download It From Here. Otherwise Enjoy The New Features & Bug Fixes.
@SE_BIBEL_MEK
๐ @androiddevstutorial
I've Tested This Sketchware Pro Nightly Build On realme RMX3381 Android13 Device & I Have Not Found Any Bugs(Except The Local Library Downloader Bug). But There May Be Some Unstablity Issues In Other Android Versions. So I Highly Recommend You To Backup Your .sketchware Folder Before Trying This One. If You Want The Latest Stable Build Of Sketchware Pro You Can Download It From Here. Otherwise Enjoy The New Features & Bug Fixes.
@SE_BIBEL_MEK
๐ @androiddevstutorial
๐1
How To Install Kotlin In Android Using Termux
Kotlin is a modern programming language developed by JetBrains, designed to be fully interoperable with Java and enhance the development experience for Android and other applications. Here are some key features of Kotlin:
* Concise Syntax: Kotlin aims to reduce boilerplate code, making it more concise and readable compared to Java.
* Null Safety: It includes built-in null safety features, helping to eliminate the risk of null pointer exceptions by distinguishing between nullable and non-nullable types.
* Interoperability: Kotlin can seamlessly interact with Java code, allowing developers to use existing Java libraries and frameworks.
In This Post We're Going To Learn How To Install Kotlin & Run Our First Kotlin Program In Android Using Termux.
Step1. If You Don't Have Termux App Installed On Your Android Device You Can Install It From Here.
Kotlin is a modern programming language developed by JetBrains, designed to be fully interoperable with Java and enhance the development experience for Android and other applications. Here are some key features of Kotlin:
* Concise Syntax: Kotlin aims to reduce boilerplate code, making it more concise and readable compared to Java.
* Null Safety: It includes built-in null safety features, helping to eliminate the risk of null pointer exceptions by distinguishing between nullable and non-nullable types.
* Interoperability: Kotlin can seamlessly interact with Java code, allowing developers to use existing Java libraries and frameworks.
In This Post We're Going To Learn How To Install Kotlin & Run Our First Kotlin Program In Android Using Termux.
Step1. If You Don't Have Termux App Installed On Your Android Device You Can Install It From Here.