|
-
Mar 15th, 2011, 06:54 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Printing picture box - alignment issue
im using this code to print a picture box
Code:
Picture1.Picture = LoadPicture("C:\scans\5.bmp")
Printer.PaintPicture Picture1.Picture, -500, 800, Picture1.Width * 0.4, Picture1.Height * 0.3
the image file dimensions are 296 x 420. my problem is i cant get the width and height correct cause i want to shrink the image to about an inch high and 3/4 inch wide. when i use the above it is like the image is not centered. i dont mean the x & y cordinates but the image itself is to the left. hope that makes sense.
-
Mar 15th, 2011, 07:28 AM
#2
Re: Printing picture box - alignment issue
-500 moves the picture to the left. Try changing it to see if the results are what you are looking for.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Mar 15th, 2011, 08:59 AM
#3
Re: Printing picture box - alignment issue
This will print the image one inch high with the width being proportional to the original picture in the center of the page.
Code:
Private Sub Command1_Click()
Dim intWidth As Integer
Dim intHeight As Integer
Dim sngRatio As Single
Dim x As Integer
Dim y As Integer
Picture1.Picture = LoadPicture("C:\scans\5.bmp")
' Get the new width and height for the printed image
' Here the image will be 1440 twips high - 1 inch
' The width will be proportional to the original image
sngRatio = 1440 / Picture1.ScaleHeight
intHeight = 1440 '
intWidth = Picture1.ScaleWidth * sngRatio
' Find the location to print the image in the center of the page
x = (Printer.ScaleWidth - intWidth) / 2
y = (Printer.ScaleHeight - intHeight) / 2
Printer.PaintPicture Picture1.Picture, x, y, intWidth, intHeight
' Release the job to the printer
Printer.EndDoc
End Sub
-
Mar 15th, 2011, 11:53 AM
#4
Thread Starter
Hyperactive Member
Re: Printing picture box - alignment issue
Ah i was all wrong. your code make the image look just like the original. the only issue i have now as your comments say, the image is in the center. i need it to be at the top left, to the left of the text i have in this code. how can i adjust the physical position x cord and y cord's. here is what i have now
Code:
Dim intWidth As Integer
Dim intHeight As Integer
Dim sngRatio As Single
Dim x As Integer
Dim y As Integer
Picture1.Picture = LoadPicture("C:\scans\5.bmp")
' Get the new width and height for the printed image
' Here the image will be 1440 twips high - 1 inch
' The width will be proportional to the original image
sngRatio = 1900 / Picture1.ScaleHeight
intHeight = 1900 '
intWidth = Picture1.ScaleWidth * sngRatio
' Find the location to print the image in the center of the page
x = (Printer.ScaleWidth - intWidth) / 2
y = (Printer.ScaleHeight - intHeight) / 2
Printer.PaintPicture Picture1.Picture, x, y, intWidth, intHeight
Printer.FontSize = 11
Printer.CurrentX = 300: Printer.CurrentY = 500: Printer.FontBold = True: Printer.Print "WELLINGTON REGIONAL MEDICAL CENTER"
Printer.FontSize = 10
Printer.CurrentX = 2000: Printer.CurrentY = 1000: Printer.Print "Name: " & FirstNameBox.Text & " " & LastNameBox.Text
Printer.CurrentX = 2000: Printer.CurrentY = 1300: Printer.Print "Date: " & Date
Printer.CurrentX = 2000: Printer.CurrentY = 1600: Printer.Print "Time: " & Format(Time, "h:mm AM/PM")
Printer.CurrentX = 2000: Printer.CurrentY = 1900: Printer.Print "Entrance: " & strEntrance
Printer.CurrentX = 2000: Printer.CurrentY = 2200: Printer.Print "Destination: "
Printer.CurrentX = 2000: Printer.CurrentY = 2500: Printer.FontSize = 15: Printer.Print strDestination
Printer.EndDoc
-
Mar 15th, 2011, 11:59 AM
#5
Re: Printing picture box - alignment issue
x = 0 and y = 0 will print the image at the top left of the page.
-
Mar 15th, 2011, 12:45 PM
#6
Thread Starter
Hyperactive Member
Re: Printing picture box - alignment issue
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|