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 / Can save image in DBPro be used to save PNG files?

Author
Message
Bluespark
15
Years of Service
User Offline
Joined: 18th Mar 2011
Location:
Posted: 17th Aug 2011 01:39
According to the help file (accessed by pressing F1 in DBPro), it only listed "BMP", "DDS", "JPG" and "DIB", but I was uncertain of whether this was actually correct.

Thanks.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Aug 2011 01:53
From help files

Quote: "SAVE IMAGE

This command will save an image to a file.

Syntax
SAVE IMAGE Filename, Image Number
SAVE IMAGE Filename, Image Number, Compression Mode
Parameters
Filename
String
Filename string
Image Number
Integer
You must specify an existing image number between 1 and 65535
Compression Mode
Integer
A zero will save the image as a D3DFMT_A8R8G8B8. Where as a value from one to five will specify a format of D3DFMT_DXT? where ? is
the value you passed in

Returns

This command does not return a value.

Description

You must specify an existing image number between 1 and 65535. The file must not already exist, otherwise the command will fail. The image
file format is determined by the extension given, and can be one of "BMP", "DDS", "JPG" and "DIB"."



I'm not a grumpy grandpa
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Aug 2011 08:19
Yes, if you can load a particular image format you can save it too as long as you add the file extension (so Darkbasic Pro knows what format you want it to use). PNG is the most useful image formats to use so it's definitely in the list of formats we can save despite the help files not mentioning it.

Run this and check the directory you ran it from:


BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Aug 2011 12:12
PNG works for me. The best way as Grog says is just to try it, it takes less time than waiting for a reply on the forum

basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 17th Aug 2011 18:44
PNG & GIF are fine it works for me and i use it all the time.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Aug 2011 20:49
Whenever I need to change an image's format I usually find the quickest way is to write a 2 line DBPro program, e.g.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Aug 2011 21:24
When saving as a JPG, what default compression scale does DB use? It can make a huge difference in quality.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Aug 2011 17:18
Good question.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 27th Aug 2011 12:52 Edited at: 27th Aug 2011 12:53
Quote: "When saving as a JPG, what default compression scale does DB use? It can make a huge difference in quality."

=
Quote: "Phaelax
Silver Codemaster"


then

Quote: "Good question."

=
Quote: "Green Gandalf
Valued Member"


then

Me = ......... ROFL

Sorry just had to point that out love you guys really make my days...
Nevertheless... I too would like to know the answer to that very same question... I love the code to basically load an image and save it as something else... but it did raise the question Phaelax brought up.
I hope My bump may attract a response but reading that rsponse from Green Gandalf... woooo boy made My day and it is raining here right now... pretty heavy and I got to ride my bike to work later... hopefully that response will keep me smiling the more I think about it haha...

But here is an interesting question... can we change attributes of an image? such as Alpha channels? to get that transparent image effect in PNG's? I ask because I could never figure it out in GIMP... I want to use them for that transparent effect in 3DWS... just no idea how to play about with that Alpha channel thing... maybe a simple bit of code? I think umm forgot his name he made that tutorial on YT think he used TGA's... {Dave Foreman?} I couldn't follow the creation of the image files...

EDIT

Regarding the ROFL... some might know i have an open sense of humour so I find fun in the smallest of things sorry I never mean anything bad by my humour... just enjoy seeing the funny side of things... helps life seem that little bit sweeter .

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Aug 2011 13:18
Quote: "When saving as a JPG, what default compression scale does DB use?"

It uses whatever quality that Microsoft hard-coded into the API.

Bluespark
15
Years of Service
User Offline
Joined: 18th Mar 2011
Location:
Posted: 27th Aug 2011 19:12 Edited at: 27th Aug 2011 19:14
Quote: "But here is an interesting question... can we change attributes of an image? such as Alpha channels? to get that transparent image effect in PNG's?"


Yes, use a memblock.

And then you start writing the colors in, byte by byte. For example, to make a pixel semi-transparent blue, you would use:

The order for writing the color is; write the byte for blue, then green, then red, then alpha.

Login to post a reply

Server time is: 2026-07-10 13:45:02
Your offset time is: 2026-07-10 13:45:02