Excellent, thank you-
using image.duplicate() is (of course) much faster than creating a new image from member.image.
Now I can use this function to create duplicate images from any size original to any size with rounded corners.
(I also use it to show the larger images)



--aTemplate=the member of the template image (with rounded corners) --aTemplateImage=aTemplate.image --inMember=the member of the larger image --outMember=new(#bitmap) --aMask= (member identical to aTemplate except 1 bit).image.createmask()

on createThumbNail aTemplate, aTemplateImage, inMember, outMember, aMask

--find proper scale
 w=float(inMember.width)
 h=float(inMember.height)
 maxWidth=float(templateImage.width)
 maxHeight=float(templateImage.height)

 diffw=maxWidth/w
 diffh=maxHeight/h

--use the min diff to scale without cropping (creating black sides or top as needed), or
--use the max diff to scale with cropping either width or height as needed
--note the "if then" statement was tested to be quite a bit faster than min or max functions
if diffw<diffh then
neww=diffw*w
newh=diffw*h
else
neww=diffh*w
newh=diffh*h
end if


 aleft=(maxwidth-neww)/2
 atop=(maxHeight-newh)/2
 destRect=rect(aleft,atop,aleft+neww,atop +newh)

 tmpImage=templateImage.duplicate()
 outImage=templateImage.duplicate()

 --PASS 1
  --create thumbnail out of larger image
  tmpImage.copyPixels(inMember.image, destRect,inMember.rect)

  --PASS 2
  --now round the edges of thumbnail
  outImage.copyPixels(tmpImage,destRect,destRect,[#maskimage:amask])
  outMember.image=outImage
end




Thank you,

   Stephen Ingrum

   <mailto:[EMAIL PROTECTED]>



Buzz Kettles wrote the following on 9/9/2004 9:16 PM:

At 5:28 PM -0500 9/9/04, you wrote:

I'm trying to create a series of thumbnails with rounded corners. Do I *have* to do it in two passes (see below)?


yes - but you might save a little processing time, by moving the creation of outImage up
(to just below the tmpImage creation)


outImage = tmpImage.duplicate()

also destRect is the same as aTemplate.rect so you don't really need that variable either

hth
-Buzz


It works fine, just trying to optimize...

--aTemplate=the member of the template image (160x120 with rounded corners)
--inMember=the member of the large image
--aMask= (member identical to aTemplate except 1 bit).image.createmask()
--outMember=new(#bitmap)



on createThumbNail aTemplage, inMember, outMember --get thumbnail template image tmpImage=aTemplate.image.duplicate() --simplified for list purposes destRect=rect(0,0,160,120)

   --PASS 1
   --create thumbnail out of larger image
   tmpImage.copyPixels(inMember.image, destrect,inmember.rect)

   --PASS 2
   --now round the edges of thumbnail
   outImage=aTemplate.image.duplicate()
   outImage.copyPixels(tmpImage,destRect,destRect,[#maskimage:amask])
   outMember.image=outImage
end



--

   Thank you,

   Stephen

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]


[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]

Reply via email to