Create a Transparent Jpg with circle and merge with another jpg and save to file

New to FreeBASIC? Post your questions here.
Post Reply
Masconti
Posts: 2
Joined: Apr 08, 2017 15:55

Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by Masconti »

Hi,
I'm a novice. I need to create a transparent jpg file with circles at some ponts and superpose that image to another jpg and save the merge to another file.
Thank you in advance for a little help
Masconti
Boromir
Posts: 463
Joined: Apr 30, 2015 19:28
Location: Oklahoma,U.S., Earth,Solar System
Contact:

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by Boromir »

Jpeg doesn't support transparency. You will have to use another image format. .png or 32 bit bmp maybe. Freebasic has internal support for the latter.
Last edited by Boromir on May 08, 2017 0:56, edited 2 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by D.J.Peters »

With fbImage you can save images with transparent (alpha) channel as *.PNG files.

Joshy
Masconti
Posts: 2
Joined: Apr 08, 2017 15:55

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by Masconti »

Thank you for your answer.
My need is to put in evidence with some small circles png image points
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by leopardpm »

D.J.Peters wrote:With fbImage you can save images with transparent (alpha) channel as *.PNG files.

Joshy
or he could just save the images as transparent BMPs without any additional libraries... but, very little support for those out there

but, if we take what he asks for, bit by bit, we can deduce that he really does not need any transparent format:

"I need to create a transparent jpg file with circles at some ponts and superpose that image to another jpg and save the merge to another file. "

Image #1: Raster Image with transparency and a few circles at certain points

Image #2: Raster Image

Image #3: Overlay Image #1 on top of image #2 and save the resulting file (does not need transparency anymore)

So the questions are:

(A) Do we fully create Image #1 from code, or are we loading up an existing image and making circles and such?

(B) What is the filetype of the existing image #2?

(C) What is the desired format of the final image? - since it does not need transparency, it can be any type of file.
If the answer to A is 'Yes, we are creating the image' and the answer to B & C is BMP, then we do not need any additional libraries....
thesanman112
Posts: 538
Joined: Jul 15, 2005 4:13

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by thesanman112 »

You want to take a jpg and make clear circles on it??

Thats easily accomplished.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by leopardpm »

thesanman112 wrote:You want to take a jpg and make clear circles on it??

Thats easily accomplished.
but it is impossible to save the resulting image, with some parts transparent, back as a JPG file since JPG does not support transparency...
thesanman112
Posts: 538
Joined: Jul 15, 2005 4:13

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by thesanman112 »

just convert the file in windows paint, then load the bitmap, draw some circles on it that you want with drawing primitives, and save the bitmap...then load it in windows paint and save as JPG again if need be.

but truth be told I know theres code for loading a JPG in FB, seen it before...just don't know where....
thesanman112
Posts: 538
Joined: Jul 15, 2005 4:13

Re: Create a Transparent Jpg with circle and merge with another jpg and save to file

Post by thesanman112 »

obviously you could add a little code to control a mouse on the screen and could either make circles of preset size or
use a couple keys to add or subtract to a circle on the screen, and allow user to save the file when needed,,,,why not just use windows paint and do
everything needed???

Code: Select all

dim as integer x,size
screenres 640,480,32,2
screenset 1,0

'****remove following rems to make a BITMAP to draw on, and saves to file.
'for x=1 to 1000:pset(int(rnd*640),int(rnd*(480))),rgb(int(rnd*255),int(rnd*255),int(rnd*255)):next
'bsave "bitmap.bmp",0,24 
    
bload"bitmap.bmp"

for x=1 to 25
    size=int(rnd*100)
circle(int(rnd*640),int(rnd*480)),size,rgb(int(rnd*255),int(rnd*255),int(rnd*255))
next x

screenset 0,1
sleep
Post Reply