Feather V1.2

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

Feather V1.2

Post by rbytes » Fri Mar 16, 2018 6:38 pm

Now works with all devices. Image resolution will be maintained as close as possible to the original, depending on device resolution.

Here is a 2048 x 1536 cloud image processed by my iPhone 6, which reduced it to 1136 x 852 pixels. It kept the
4:3 aspect ratio by using virtual screen memory.

iphone.png
iphone.png (1.72 MiB) Viewed 1340 times

There is a bug in Smart Basic that prevents me getting the full resolution possible.
1136 x 852 pixels is only what an iPhone 5s is capable of.
This image should should be 1334 x 1001, according to the iPhone 6 specifications.
Although the iPhone 6 vertical resolution is only 750 pixels, its virtual screen should
max out at 1001.

Code: Select all

/*
Feather V1.2 by rbytes
March 2018

V1.2 Now works with all devices. It will process photos at as close to
the original size as possible depending on your device's resolution.

V1.1 The image is now processed into a sprite. Afterward, if the screen
is cleared to a color instead of transparency before stamping the sprite,
you will produce a color-edged vignette instead of a feathered edge.

V1.0 Feathers the edges of a photo (fades them to transparent)
Recommended photo size is 2048 x 1536 pixels
eg. iPad screenshot, photo shared via PhotoStream
works only on iPad
*/
SET TOOLBAR OFF
sw=SCREEN_WIDTH()
sh=sw*.75
rw=sw/1024
fsize=128  ' width of the feathered edge
GRAPHICS
SPRITE "stamp" BEGIN sw,sh
DRAW IMAGE "scope.jpg" AT 0,0 SCALE .5*sw
FOR y=0 TO sh*2
  A3=1
  IF y<fsize THEN A3=y/fsize                ' feather top
  IF y>sh*2-fsize THEN A3=(sh*2-y)/fsize    ' feather bottom
  FOR x=0 TO sw*2
    A2=1        
    GET PIXEL x,y COLOR R,G,B,A
    IF x<fsize THEN A2=x/fsize              ' feather left side
    IF x>sw*2-fsize THEN A2=(sw*2-x)/fsize  ' feather right side
    DRAW PIXEL x,y COLOR R,G,B,A2*A3
  NEXT x
NEXT y
SPRITE "stamp" END
'GRAPHICS CLEAR 0,.2,.4       ' uncomment for a vignette color
GRAPHICS CLEAR                ' uncomment for a feathered edge
PAUSE 1
SPRITE "stamp" SHOW
PAUSE 2
SPRITE "stamp" SAVE "feather.png"
ALBUM EXPORT "feather.png"
####### Living the colorful life #######

Post Reply