For some picture print producion I used printomatic full version 1.6.2
In there I used the code drawPicture which should fit an image (bij scaling)
into a specified rect.
To check if a landcape mode is needed I have checked the size orientation of
the cast member of the picture.
In portait mode all calculations and resizing seems to be working fine, but
if the mode switches to landscape no scaling is done anymore.
But all rest works fine....
Is is me that does not see the problem, or is it a printomatic bug?
The following code I made to center the picture on the paper and scale the
pictures to a specifield rect. (maximized over the paper)
Can somebody give me feedback where:
1. if there is a bug by printomatic, how to work around it?
2. If I do something wrong, what is wrong?
3. If things can done better, what and why?
And before I get questions about the configuration:
- I use a canon BJC6000 inktjet printer
- I'm working on 32 bits color format, but the program (till now) is also
programmed work into 16 bit depth
Kind regards,
Wilbert Maximus
---- Behavior Code:
global isLandscape -- is set when landscape detected by loading the picture
into the cast (other behavior)
global MyIMember -- is member 50 of the first cast
global isLoaded -- is set when picture is succelfull loaded (other behavior)
property pLeft, pTop, pwitdh, pHeight -- Page properties
on mouseUp me
if not isLoaded then
alert "some text"
else
-- create and test Drawing object
set Drawing = new(Xtra "PrintOMatic")
if not objectP(Drawing) then
alert "some other text"
exit
end if
-- initiate paper values
setDocumentName Drawing, "The documentName"
setProgressMsg Drawing, "Printing"
if isLandscape then setLandscapeMode Drawing, TRUE
else
setLandscapeMode Drawing, FALSE
end if
setPrintableMargins Drawing, -- maximum printable area supported by the
default printer
Dw = getPageWidth(Drawing)
Dh = getPageHeight(Drawing)
newPage Drawing
MyRect = Rect(0,0,Dw,Dh)
MyRect = CenterDrawing(me,Rect(0,0,Dw,Dh)) -- CalculatePicture margins
to center.
-- Set font, machine specific
if the platform contains "Windows" then
setTextFont Drawing, "Arial"
SettextSize Drawing , 10
SetTextStyle Drawing, "normal,Bold"
SetTextJust Drawing, "right"
else
setTextFont Drawing, "Monaco"
SettextSize Drawing , 10
SetTextStyle Drawing, "extend"
SetTextJust Drawing, "right"
end if
-- Insert picture and copyright notes
drawpicture Drawing, member(MyIMember,"Internal"),MyRect,TRUE
paperX = Dw - 28
paperY = Dh - 28
drawText Drawing, "(c) The CD-ROM Name", Point(paperX,paperY)
-- print the drawing
if doJobSetup(Drawing) then
updateStage
if the shiftDown then
printPreview(Drawing)
else
print Drawing
end if
end if
updateStage
-- reset/delete the printobject
Drawing = 0
end if
end
on CenterDrawing me, TheRect
-- Calc new rect
TempWidth = member(MyIMember,"Internal").width
TempHeight = member(MyIMember,"Internal").height
TheRect.Bottom = TheRect.Bottom - 28 -- Make 28 pixels (= 1cm) space at
the bottom for copyright info
if ((TempWidth.float / TheRect.Right) > (TempHeight.float /
TheRect.Bottom)) then
MyFactor = (TempWidth.float / TheRect.Right)
else
MyFactor = (TempHeight.float / TheRect.Bottom)
end if
TempWidth = Integer(TempWidth / MyFactor) -- Get the Width of the picture
TempHeight = Integer(TempHeight / MyFactor) -- Get the Height of the
Picture
-- Center the picture on the page
TheRect.Left = Integer((TheRect.Right - TempWidth) / 2)
TheRect.Top = Integer((TheRect.Bottom - TempHeight)/2)
return Rect(TheRect.Left,TheRect.Top,TempWidth,TempHeight)
end
The problem was solved by my collegue
(it was may fault, not a print-O-matic bug.)
For who wants to read the solution:
Print-O-matic scales without disortion.
That means, any fault into the rect dimensions, causes unexpected rescaling.
Wehn shifting the left or top, the Right or bottom has to be shifte to.
That was what failed.
The routine "on CenterDrawing me, TheRect" was not correct.
return Rect(TheRect.Left,TheRect.Top,TempWidth,TempHeight)
had to be, return Rect(TheRect.Left, TheRect.Top, TempWidth + TheRect.Left,
TempHeight+TheRect.Top)
Kind regards.
W. Maximus