Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Save an image with a transparency layer

Author
Message
Maindric
16
Years of Service
User Offline
Joined: 22nd Jul 2009
Location:
Posted: 18th Jun 2012 21:47
I am making a basic image editor, and I want to save an image (I don't care what format, thinking of a custom format, so even just pure data will work.) that I want to load into DBPro, and have it load with the soft transparency. I want to be able to add glow effects and such to my images, but in order to do that, I need this layer. Anyone know how this can be achieved?

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Jun 2012 22:10 Edited at: 18th Jun 2012 22:27
It's something like this...



... but may need experimenting with. The important parts are...

set bitmap format 21... which should retain alpha transparency. I have picked just the top corner of the image as the transparent colour, but you may want more transparency, which means that you might have to pick colours from the entire image.

Anyway I got it from Green Gandalf in this thread...
http://forum.thegamecreators.com/?m=forum_view&t=159714&b=1

Which is a more complete version.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 19th Jun 2012 07:32 Edited at: 19th Jun 2012 07:35
No wai. If that works I'll post a working solution.
I like this better than my current method.

Leonid
User Banned
Posted: 19th Jun 2012 12:06
see dbp help and find solution by yoursels :
"make memblock" (it can contain any data and might be written onto disk)
"make memblock from image"
"make image from memblock"
"write memblock"
"read memblock"

use hidden command for byte or dword.
example "a as byte" (variable a must be from 0 to 255) if makes memblock commands faster
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 20th Jun 2012 04:58
Simply saving the memblock to a file won't work because the data isn't properly formatted.

Leonid
User Banned
Posted: 20th Jun 2012 06:56 Edited at: 20th Jun 2012 07:04
I have done it. You can not use memblock as bmp or jpg. Memblock data consist: first 4 bytes (dword) - memblock size for memory placing; data; last 1 byte - End-of-File mark. You can save memblock with any exstension (it may be and bmp too), but it can not be opened as bmp. You must convert it: "make image from memblock" and "save image".

About free programs (replacement for Photoshop): type "GIMP" in Google ("GNU Image Manipulating Program"). About free programs - replacement for CorelDraw: type "Inkscape". Free program (good for yor game making) - make it by yourself using "make mesh from memblock". I know also free 3D editor: "Blender".
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 20th Jun 2012 11:30
Every pixel is stored as a dword in a memblock, so the alpha channel is already there. Take the colour orange for example:

0xFFFF8000

FF - alpha channel
FF - red
80 - green
00 - blue

So if you just write each pixel to a file as a dword, that's all there is to it.

TheComet

Login to post a reply

Server time is: 2026-07-08 12:27:27
Your offset time is: 2026-07-08 12:27:27