Photo Zoom-In

Post Reply
User avatar
rbytes
Posts: 1969
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Photo Zoom-In

Post by rbytes » Mon Dec 10, 2018 4:06 pm

Create a dynamic zoom effect on an image. This is done by setting the draw alpha value to a fraction and repeatedly stamping the image while increasing its scale. At the end of the zoom, you can accept the final result or (in my opinion) improve it by stamping a cutout of the center of interest of the same image (with the background made transparent). These same instructions are in the program's header comments.

I am assuming that anyone using this effect has an app that can remove background areas from an image. I could be wrong. In the next week I will post a program to do that very thing. Meanwhile the final two photo attachments can be used as sample images to test the program.

Attached images:

1. Screen shot of zoom effect without final stamp of cutout.
2. Screen shot of zoom effect with final stamp of cutout (default).
3. Cutout (image with transparent background) - Name this file "painter.png" and save it in the same location as the program.
4. Original image - Name this file "Phaedra.jpg" and save it in the same location as the program.

Modelling Credits:
Our beloved Labradoodle, Phaedra (fay'-dra)

Code: Select all

/*
Photo Zoom-In
by rbytes
December 2018
Creates a dynamic zoom-in effect on a photo
and saves a .jpg image.
Results are best if you stamp a sprite of
the same image with the background removed.
Tap the screen to end the program.
*/
OPTION SPRITE POS CENTRAL
laun$=LAUNCHER$ ()
SET TOOLBAR OFF
GET SCREEN SIZE sw,sh
itest=0
IF itest THEN
  sw=568
  sh=320
ENDIF
rw=sw/1024!rh=sh/768
alf =.05*(1/rw)
N$="Phaedra.jpg"
S$="painter.png"
GRAPHICS
GRAPHICS CLEAR

' create the zoom effect using the complete image
'GRAPHICS MODE MULTIPLY   ' uncomment for a more dynamic look
GET IMAGE N$ SIZE WI,HI
SPRITE "main" LOAD N$
SPRITE "main" SHOW
FOR t=0 TO 100 'STEP 2
  SPRITE "main" AT sw/2,sh/2 SCALE (sw/WI)*t/100
  SPRITE "main" ALPHA alf
  SPRITE "main" STAMP
NEXT t


' load the same image with the background removed (made transparent).
' this section can be commented out if you wish
GET IMAGE S$ SIZE WI,HI
SPRITE "trans" LOAD S$
SPRITE "trans" ALPHA .5
SPRITE "trans" AT sw/2,sh/2 SCALE sw/WI
SPRITE "trans" SHOW

GRAPHICS SAVE 0,0, sw,sh TO "photo zoom-in.jpg"
wait:SLOWDOWN!GET TOUCH 0 AS tx,ty!IF tx=-1 THEN wait
IF laun$="desktop" THEN
  IF FILE_EXISTS("/launch") THEN
    RUN "/-Launch.sb"
  ELSE
    EXIT
  ENDIF
ENDIF
END
Attachments
AD8428D2-61B6-40C3-B78D-D0F239B61373.png
AD8428D2-61B6-40C3-B78D-D0F239B61373.png (7.13 MiB) Viewed 105 times
74EC81FA-D848-479E-891E-A7E26C6BA7E1.png
74EC81FA-D848-479E-891E-A7E26C6BA7E1.png (7.22 MiB) Viewed 105 times
F9DB21B5-5B31-4344-A68C-809866896C37.png
F9DB21B5-5B31-4344-A68C-809866896C37.png (805.6 KiB) Viewed 105 times
AD136B7C-7D9F-44DB-9209-037686917BC3.jpeg
AD136B7C-7D9F-44DB-9209-037686917BC3.jpeg (2.34 MiB) Viewed 105 times
####### Living the colorful life #######

Post Reply