Hi
In below code i want to save img variable. Below is the code
Dim img As StdPicture
Set img = LoadPicture(App.Path & "O" & TrNo & Format(Date, "ddmmyyyy") & ".jpg") ' Load your image here
Dim lSourceX As Long, lSourceY As Long
Dim lOldWidth As Long, lOldHeight As Long
Dim lNewWidth As Long, lNewHeight As Long
lOldWidth = Picture1.ScaleWidth \ Screen.TwipsPerPixelX
lOldHeight = Picture1.ScaleHeight \ Screen.TwipsPerPixelY
lNewWidth = lOldWidth * 0.7
lNewHeight = lOldHeight * 0.7
lSourceX = (lOldWidth - lNewWidth) \ 2
lSourceY = (lOldHeight - lNewHeight) \ 2
img.Width = img.Width - img.ScaleWidth + (lNewWidth * Screen.TwipsPerPixelX)
img.Height = img.Height - img.ScaleHeight + (lNewHeight * Screen.TwipsPerPixelY)
Thanks
Sangeetha SPosted Mar 21, 2025, 5:10 AM
Using Visual Basic 6.0 (VB6), and you want to save the
StdPictureobjectimgto a file after resizing it. VB6 doesn't have a direct built-in method to save aStdPictureto a file. You'll need to use a workaround, typically by:StdPictureto a PictureBox.Imageproperty to a file.Here's how you can modify your VB6 code to achieve this:
VB.Net
Emily FosterPosted Mar 20, 2025, 9:59 AM
Based on the given code snippet, it seems like you are loading an image file into a variable `img` using Visual Basic. The code snippet is adjusting the dimensions of the loaded image (`img`) by resizing it based on certain calculations.
If you want to save the `img` variable back to a file after the resizing operations have been performed, you would typically need to use a method to save the image. However, in Visual Basic using the `StdPicture` data type, there isn't a direct method to save the image back to a file.
One common approach to save the image would involve using external libraries or APIs that support image manipulation and saving, or converting the `img` variable to a different image format that can be saved using native Visual Basic functionality.
Here is a generic example of how you might approach saving the image using an alternative approach:
In this example, the `SaveImageToFile` subroutine converts the `StdPicture` to a BMP image using the Windows Imaging Acquisition (WIA) library and then saves it to a specified file path. Remember to adjust the code above based on your specific requirements and environment.
Since direct saving of an `StdPicture` object may not be natively supported in Visual Basic, leveraging external libraries or custom functions like the example above can help achieve the desired outcome.