0
To save or display the center of the picture in another picture, you can use the PaintPicture
method to copy the central portion of the image. Here's an example of how you can achieve this:
Sub SaveCenterOfPicture()
Dim centerX As Long
Dim centerY As Long
Dim centerWidth As Long
Dim centerHeight As Long
' Set the dimensions of the center portion
centerWidth = 50000
centerHeight = 28000
centerX = (Picture1.Picture.Width - centerWidth) / 2
centerY = (Picture1.Picture.Height - centerHeight) / 2
' Create a new picture box to hold the center portion
Picture2.AutoRedraw = True
Picture2.Width = centerWidth
Picture2.Height = centerHeight
' Copy the center portion of Picture1 to Picture2
Picture2.PaintPicture Picture1.Picture, 0, 0, centerWidth, centerHeight, centerX, centerY, centerWidth, centerHeight
' Save Picture2 to a file
SavePicture Picture2.Image, App.Path & "\Center_" & tno & ".jpg"
End Sub
0
Based on the information provided, it seems like you are looking to work with images and extract/display the center of an image in another picture.
To achieve this, you can determine the center of the image based on its dimensions (Width = 50000, Height = 28000) and then capture or display that center in another picture.
Here is an example of how you can modify the code snippet you shared to achieve this:
' Calculate the center of the image
Dim centerX As Integer
Dim centerY As Integer
centerX = Picture1.Width \ 2 ' Integer division to find the center along the X-axis
centerY = Picture1.Height \ 2 ' Integer division to find the center along the Y-axis
' Create a new picture to display the center of the image
Dim Picture2 As Object ' Define Picture2 as your new Picture object
Set Picture2 = CreateObject("Forms.PictureBox") ' Create a new Picture object
Picture2.AutoRedraw = True
Picture2.Width = 100 ' Set the width of Picture2
Picture2.Height = 100 ' Set the height of Picture2
' Capture the center of the original image and display it in Picture2
Picture2.PaintPicture Picture1.Picture, 0, 0, 100, 100, centerX - 50, centerY - 50, 100, 100
' Adjust the position and size (100x100) of the center image as needed in Picture2
' You can then save Picture2 as a new image file if required
' Make sure to properly dispose of Picture1 and Picture2 objects when done
Set Picture2 = Nothing
In this code snippet:
- We calculate the center of the original image.
- We create a new PictureBox object (Picture2) where we will display the center of the original image.
- We use the `PaintPicture` method to extract the center of the original image and display it in Picture2.
- Finally, you can save the resulting center image if needed.
Please customize the code further based on your specific requirements and the tools you are using, as this is just a conceptual example. Let me know if you need more specific guidance or have any other questions!
