Hi
In below code i want that Original Image should get cropped to fit in another Picture whose size is 3000 X 3000
Dim originalPic As PictureBox
Dim croppedPic As PictureBox
Set originalPic = Picture1 ' Set your source PictureBox
Set croppedPic = Picture2 ' Set your destination PictureBox
' Centre of the original image
Dim centerX As Long, centerY As Long
centerX = originalPic.ScaleWidth / 2
centerY = originalPic.ScaleHeight / 2
Thanks
Muhammad Imran AnsariPosted Mar 23, 2025, 11:47 AM
Hello Ramco,
To crop the original image so that it fits into another
PictureBoxwith a 3000 × 3000 size, you need to center the crop area and ensure a square selection. Below is the updated VB6 code to accomplish this:Good Luck!
Daniel WrightPosted Mar 23, 2025, 5:57 AM
Based on the provided code snippet, it seems like you are on the right track to crop an image in VB6. To crop the original image to fit into another Picture whose size is 3000 X 3000, you can use the following steps:
1. Determine the cropping dimensions based on the original image size and the desired size of the destination Picture.
2. Calculate the cropping coordinates to extract the desired portion of the original image.
3. Copy the cropped portion of the original image to the destination Picture.
Here is an example code snippet that you can use to crop the image:
This code snippet calculates the cropping dimensions based on the original image size and ensures that the cropped portion fits within a 3000 X 3000 frame. It then extracts the desired portion of the original image and displays it in the destination PictureBox.
Feel free to customize this code further based on your specific requirements or if you need additional functionality. Let me know if you have any more questions or need further assistance!