Mask and saving picture 
Author Message
 Mask and saving picture

Can anyone tell me why the following code doesn't work. I am trying to
take a photograph, create a mask around it that crops a rectangular
picture into an oval, and save the resulting image as a jpeg. When I
push the save button, the picture moves out of the realbasic window and
overlaps onto the desktop and an empty data file is created.  Can you
tell me what I'm doing wrong. Any help is much appreciated. Thanks.

property p as picture

canvas1 open
sub Open()
dim h,w,i as integer
w = skilletball.width
h = skilletball.height
editfield1.text = str(w)
editfield2.text = str(h)
p = newpicture(w,h,32)
p.graphics.drawpicture skilletball,0,0
p.mask.graphics.forecolor = rgb(255,255,255)
p.mask.graphics.fillrect 0,0,w,h
for i = 0 to 15
p.mask.graphics.forecolor = rgb((15-i)*16, (15-i)*16, (15-i)*16)
p.mask.graphics.filloval i,i,w-2*i,h-2*i
next
canvas1.backdrop = p
endsub

pushbutton1.action
sub Action()
dim f as folderitem
f = getsaveFolderItem("image/jpeg","untitled")
if f<> nil then
f.saveaspicture p
end if
endsub



Wed, 25 Dec 2002 03:00:00 GMT  
 Mask and saving picture

Quote:

> Can anyone tell me why the following code doesn't work. I am trying to
> take a photograph, create a mask around it that crops a rectangular
> picture into an oval, and save the resulting image as a jpeg. When I
> push the save button, the picture moves out of the realbasic window and
> overlaps onto the desktop and an empty data file is created.  Can you
> tell me what I'm doing wrong. Any help is much appreciated. Thanks.

> property p as picture

> canvas1 open
> sub Open()
> dim h,w,i as integer
> w = skilletball.width
> h = skilletball.height
> editfield1.text = str(w)
> editfield2.text = str(h)
> p = newpicture(w,h,32)
> p.graphics.drawpicture skilletball,0,0
> p.mask.graphics.forecolor = rgb(255,255,255)
> p.mask.graphics.fillrect 0,0,w,h
> for i = 0 to 15
> p.mask.graphics.forecolor = rgb((15-i)*16, (15-i)*16, (15-i)*16)
> p.mask.graphics.filloval i,i,w-2*i,h-2*i
> next
> canvas1.backdrop = p
> endsub

> pushbutton1.action
> sub Action()
> dim f as folderitem
> f = getsaveFolderItem("image/jpeg","untitled")
> if f<> nil then
> f.saveaspicture p
> end if
> endsub

The parameter "image/jpeg" in the GetSaveFolderItem function should be
empty (You can read it at the end of the online help (in the IDE), just
before the example). This can solve some problems.


Wed, 25 Dec 2002 03:00:00 GMT  
 Mask and saving picture
I've tried your suggestion, but I am still unable to get it to work. I have
tried to parallel my code to the printed developer's guide, particularly
pages 270-272.
Quote:

> The parameter "image/jpeg" in the GetSaveFolderItem function should be
> empty (You can read it at the end of the online help (in the IDE), just
> before the example). This can solve some problems.



Thu, 26 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. picture mask problem

2. Does the the picture mask work well on a PC

3. picture masks?

4. Transparent icon or mask or pictures

5. SET CENTURY ON and Picture Masks

6. mask and save

7. Saving a picture to file- colour depth problem?

8. Saving Picture in Database

9. Save Picture in a database

10. How to WRITE/SAVE picture data into BMP format

11. How to save picture to a BMP file?

12. saving jpg picture files

 

 
Powered by phpBB® Forum Software