main logo
Subject: Re: V4RB : Getting Pictures, and Scaling on Mac and Windows.
Author: Robert Garcia
Posted: 2001/05/30 11:42:25
 
View Entire Thread
New Search


Here is a method that is an action of a button to display a dialog and allo=
w
the user to pick an image and put it into a blob, "mImage.Thumb" is a blob
reserved for a 90w x 60h thumbnail of the image, and "mImage.Image" is the
entire image.:

EventWindow.EP_AddPhoto.Action:
Sub Action()
dim f as folderItem
dim buffer,temp,image as picture
dim id,cat as string
dim clip as clipboard
f =3D GetOpenfolderItem("special/any")
if f =3D nil then
return
end if
buffer =3D f.openasPicture
if buffer =3D nil then
msgBox "Not Enough Memory!"
return
end if
temp =3D scaletofit(buffer,90,60,)
clip =3D new clipboard
clip.picture =3D temp
if clip.picture =3D nil then
msgBox "Not enough memory to continue!"
return
end if
MainWindow.db.mImage.Thumb.Setblank
MainWindow.db.mImage.Thumb.SetPicture(clip.picture,100)
clip.close
clip =3D new clipboard
clip.picture =3D buffer
if clip.picture =3D nil then
msgBox "Not enough memory to continue!"
bhprogress.close
return
end if
MainWindow.db.mImage.Image.SetBlank
MainWindow.db.mImage.Image.SetPicture(clip.picture,100)
clip.close
MainWindow.db.mImage.addRecord
if MainWindow.db.errnumber <> 0 then
msgBox MainWindow.db.errstring
return
end if
MainWindow.db.flush
End Sub

Please notice the use of the clipboard. This is completely essential many
time in RB when using images. It is a bug. Also, this bug doesn't seem to
always occur in windows, and in fact I had a crash in windows that I traced
to the clipboard workaround, when I removed it, no crash, and everything
worked?! AT #$

Also, scaletofit(p as picture, w as width, h as height) is part of a module
that I wrote for scaling pictures within a defined area without distorting
their aspect ratio .DO.T It uses drawpicture to scale on a mac, and a complicate=
d
rgbsurface loop for windows. Their is a bug with drawpicture on windows tha=
t
distorts images horribly. I have spoken with RB at great length, and so far
they only verified its existence.

If you need the module, let me know, and I can get it to you privately,
however, it took me hours to write these workarounds and I feel like I
should charge a nominal fee for it. The module includes image rotatation
left or right by 90=BA, flip horizontal, flip vertical, and scaling to fit. I
have also worked out a scrolling canvas for large images that allows you to
draw a rectangle on the image and crop, and then updating your blob. All of
this work was done for a project that must run on Mac, Mac OS X, and window=
s
95/98/NT/2000/Me and I have verified that it works on all.

Robert Garcia
BigHead Technology

> From: Jan Paaske <jpaaske@broadway.co.uk>
> Reply-To: valentina AT lists .DO.T macserve.net (Subscribers of Valentina)
> Date: Thu, 24 May 2001 15:54:48 +0100
> To: valentina@lists.macserve.net (Subscribers of Valentina)
> Subject: V4RB : Getting Pictures
>=20
> Hi List
>=20
> I have worked with VAPP and Apple Script for a year now, and I am just
> starting to learn Real Basic.
>=20
> I am just starting working on my first V4RB project where I need to get
> thumbnails from folders full of images. These could be TIFF, EPS, JPG in
> CMYK or RGB format. I need these jpeg thumbnails to go into a BLOB field =
in
> V4RB and for my database when queried to include them in the HTML reply.
>=20
> I spoke to Ruslan and he said that someone had already made such a featur=
e
> and told me to ask here on the list. Can anyone help with code and advice
> please?
>=20
> Many thanks
>=20
> Jan Paaske


-------------------------------------------------------------
The Valentina mailing list is brought to you by MacServe.net
For info on lists services, see http://www.macserve.net/lists.html
 
©2001 Robert Garcia
<-- Prior Message New Search Next Message -->