Forum

> > CS2D > General > Transparency and file formats
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Transparency and file formats

17 replies
To the start Previous 1 Next To the start

old Transparency and file formats

Pagyra
User Off Offline

Quote
At the moment, I personally replace all standard graphics of *.BMP files to format *.PNG, but save it filename as *.BMP .
But recently, I remembered that *.BMP format with 32 bit supports alpha channel (transparency) -
And so, there was a question to dc - is it possible to use it in CS2D (my test image is painted black) and whether it will replace the standard *.BMP to 32bit or *.PNG?
BMP is both uncompressed and lossless. PNG is compressed but lossless. Thus, with a lossless format the only visible difference is the file size(which is very useful for transferring files). I'd recommend using PNG over BMP unless you can't for compatibility reasons.

Will also connected support file formats like *. Gif and *. Apng? (At the moment, so a lot of problems with the creation of animations - a large number of frames, requires a large amount of files loaded into memory that heavily loads your computer.)

old Re: Transparency and file formats

Torque
User Off Offline

Quote
Why would you even do that?
CS2D supports png sprites just fine, also with transparency.
In bitmaps 'magic pink' can be used for transparency.

old Re: Transparency and file formats

Pagyra
User Off Offline

Quote
I use the alpha channel for many images to simulate a shadow or glow. Pink color does not give such an opportunity. Compressed image takes up less disk space - that you can use to store cs2d at smartphones and communicators.

old Re: Transparency and file formats

Pagyra
User Off Offline

Quote
I know perfectly well how to make any image transparent
how to make long-term, full-screen animation and stuff.
Currently (and for this purpose it was created topic) I'm trying to optimize the game to consume less computer resources the user and the best speed by net - I need it to create complex scripts and mods.
And for this and much more hope that DC will respond at my and your questions in this topic.

I've already written the reason why I do not use any timers to show different images:

Quote
At the moment, so a lot of problems with the creation of animations - a large number of frames, requires load a large amount of files(images) into memory that heavily loads your computer.

I advise you to read full my messages for understand what i proper and want.

old Re: Transparency and file formats

DC
Admin Off Offline

Quote
BlitzMax does not support formats like gif or apng (or bmp images with alpha channels - if they exist). Especially gif support has been requested frequently but I won't implement it. That's because animated images require additional program logic (for playing the animations) and I can't simply "add" these formats without changing and adding a lot of code.

Just use PNG if you need alpha. You can also use it if you don't need alpha because it's compressed. CS2D's file transfer however compresses images (and all other files) anyway so it doesn't really matter if you use BMP or PNG. The sizes are basically the same after compression.

The approach to use PNG and to change the extension in the file name to ".bmp" is correct if you want to modify/change images of the original game. You shouldn't do this in other situations though because it leads to confusion (people expect a bmp if there is a bmp extension).

old Re: Transparency and file formats

Pagyra
User Off Offline

Quote
It is exists - http://en.wikipedia.org/wiki/BMP_file_format

Well then there is question about of multi-layered entity and moving light sources? Will it be added in the near future? And how soon will be possible to mix/blend some layers of overlapping images(sprites, textures, dyn.walls, ...)?

Maybe all this will be the solution at question of animations.

Thanks for the answer.

old Re: Transparency and file formats

DC
Admin Off Offline

Quote
Neither entity stacking (compatibility problems) nor blending/mixing of random images (performance/complexity problems) are planned.

Tile animations are possible with cs2d entity Info_Animation. That's currently the only "good" way to add animations (to maps).

I added a note about this to my todo list. It shouldn't be too hard to make a special Lua image command which supports animated images / a set of images. You shouldn't expect any CS2D updates soon. I'm working on Stranded III.

old Re: Transparency and file formats

MikuAuahDark
User Off Offline

Quote
user Dousea has written
@user MikuAuahDark: Why use cs2d lua cmd timer? How about cs2d lua hook always hook? It is repeated every 50 milliseconds. Just create a new image and delete last image if exists. After the end of the animation, show first image and repeat it forever.

It's every 20 miliseconds.
cs2d lua hook always has written
Attention: This hook is executed very frequently (~50 times per second) so do not execute very complex/slow scripts with it!
Attention: Counter-Strike 2D may run with a slower (and also slightly higher) frames per second value. Please consider this when using this hook. Do not use it for timers.

But instead deleting(cs2d lua cmd freeimage) it, just make the image opacity to 0. cs2d lua hook always is laggy for slow network player, so cs2d lua cmd timer can be used as alternative (to show slower animations).

old Re: Transparency and file formats

VADemon
User Off Offline

Quote
@user MikuAuahDark: cs2d lua hook always is executed every 20ms and it's only server-side unless you actually send something to the player. I expect cs2d lua cmd timer to be performance demanding (again, server-side) because it function uses a CS2D internal functions (correct me, if I'm wrong). An implementation in Lua (as it would be the always hook) should be much faster.

cs2d lua cmd imagealpha = 0 good idea, but should be used wisely (not everybody has gigs of ram)

old Re: Transparency and file formats

Pagyra
User Off Offline

Quote
I noticed that the transparent image loads less computer.
My version :
Creating a cycle frame number for animation, check stock images for frames and frame numbers are assigned to images, creating animation timers.
Checking distance from the screen of player to the area in which the animation will be shown, if yes then, immediately create all frames of animation (Mode 101 - 200 + id), then set full transparency for all frames except the first, and run animation through "always" hook but with timer - by successive image frames state transition from transparent to opaque.
Additionally, depending on the distance from the player to change transparency of "opaque" frames. The closer to the visible ( to the screen) will become even more opaque " opaque " frames. The farther from the area of ​​the screen so it become more transparent . If the animation is beyond two screen sizes of screen area - animation frames removed for this player.
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview