Picture fields

Kelly Burgess kellyb at montana.com
Fri Apr 24 21:07:05 EDT 2009

Hi Steve,

I do image scaling in the $print method of a positioning section that 
decides whether or not to include the picture field in that section. 
My picture field is about an inch and a half wide, half an inch tall, 
and I want it to max out at 4x4 inches, so anything bigger than 4 
inches will be scaled, otherwise not.  $noscale is kTrue, 
$keepaspectratio is false, $horz/$vertdpi are 0...  So I do this...

Do pictconvto(pictformat(fImage.IM_IMAGE),fImage.IM_IMAGE,'CS24') 
Returns picture
Do pictsize(picture,pictWidth,pictHeight) Returns return
If return&pictWidth<>0
   If (pictWidth/72>4.0)|(pictHeight/72>4.0)
     ; scale pictures larger than 4 inches wide or high...
     Calculate $cinst.$objs.recipeImage.$noscale as kFalse
     If pictWidth>pictHeight
       Calculate newWidth as 4.0
       Calculate newHeight as 4.0*(pictHeight/pictWidth)
       Calculate newHeight as 4.0
       Calculate newWidth as 4.0*(pictWidth/pictHeight)
     End If
     ; scaling on, set exact height and width of picture field
     Calculate $cinst.$objs.recipeImage.$height as newHeight
     Calculate $cinst.$objs.recipeImage.$width as newWidth
     ; no scaling, actual image width used regardless of what the field size is
     Calculate newWidth as pictWidth
   End If
   Calculate $cinst.$objs.recipeImage.$left as (7.75-newWidth)/2  ;; 
center on page
   Do default
End If

'picture' is an instance variable, used as the $dataname of the 
picture field in the section.

So I let the picture org at top/left, and rather than try to center 
it within the field I just control the left coordinate to get the 
whole thing centered on the page.


More information about the omnisdev-en mailing list