Quesiton about masked_blit
ReiKo90

Hello,

I was just wondering if anyone can explain me how in fact masked_blit works?

As we already know, masked_blit eliminates background that could be in various colors and displays sprite we want to blit to the screen.

Well, I would like to show you some example as I did experiment quite a bit with this command and I cant understand how and when it "removes" background and what are the cases needed to be satasfied in order it to do so?

1st example:

When I use masked_blit on this picture: http://img27.imageshack.us/i/doggle.png/

It sucssesfuly removes pink background and shows "doggy" in black screen background. Perfect!

2nd example:

But here I got Linux "Tux" mascot, that also has pink background. When I use masked_blit with it then it dosen't remove pink background - but in fact it displays it! :( :o

Why is that so? What needs to be done with picture in order to masked_blit only show sprite itself? Another color in bitmap's background?

I did set pixel_depth(32) also but problem with "Tux" still remains.

BUT - I did solve this in a specific way:

I used "Eyedroppe tool" from Photoshop and used "specific pink" from "doggy" picture and used it on "Tux" picture as background color.

After that - masked_blit with "Tux" picture worked PERFECT!.

So my questions is in fact:

Why does masked_blit only removes specific color of background and how to manipulate it better? Should I always color my pictures with that "specific pink" in order to masked_blit remove it afterwards? How it works is right question :)

Thanks! :)

Tomoso

The pink colour must be exactly that shade of pink for masked_blit to know it shouldn't draw it. It only treats one colour (the pink) this way because it is a lot simpliar to remember one colour you cant use when drawing sprites (unless you want it to be transparent of course).

The rgb value for that pink is (255,0,255) and I think its that pink because the colour isn't used often? Not sure though, I might have made that up.

Anyway I wouldn't worry why it works, just worry that it works with that pink only :P

ReiKo90
Tomoso said:

The pink colour must be exactly that shade of pink for masked_blit to know it shouldn't draw it. It only treats one colour (the pink) this way because it is a lot simpliar to remember one colour you cant use when drawing sprites (unless you want it to be transparent of course).

The rgb value for that pink is (255,0,255) and I think its that pink because the colour isn't used often? Not sure though, I might have made that up.

Anyway I wouldn't worry why it works, just worry that it works with that pink only :P

Thanks,

Anyway, could anyone be more technical about this?

Also, when I did put "shade of pink" on background of "Tux", in my program masked_blit did remove background, but lines of "tux" bitmap did left pink colored.

Like this:
http://img132.imageshack.us/i/87703854.jpg/

What technique should I use to make most of my bitmap's background "pink shaded" so it works perfectly with masked_blit or even with draw_bitmap?

Arthur Kalliokoski

Maybe this thread will help

http://www.allegro.cc/forums/thread/600895

ReiKo90

That topic did help me a lot, thanks.

Anyway, I just wanted to ask - no need to open another topic:

Is there easy way to me load .PNG files with Allegro? Some stabile and easy to use library with tutorials?

I am using Microsoft Visual Studio 2008 Express edition SP1.

Thanks.

Arthur Kalliokoski
ReiKo90

Thanks, but can I use this library without installing libpng and zlib? Atleast basic functions like loading .PNG file and displaying it on screen?

Arthur Kalliokoski

I don't see how you expect to use a "library" without something that has "lib" in the name, for example, liballeg.a or allegro.lib. And I assume zlib provides compression. It's not that hard to use them, really!

ReiKo90

Well in fact it is, because I don't get .lib files with it but need to get trough process of compiling them or whatnot and to things be better - it's so on Linux side of things and there is no tutorial how to implement this on VS 2008 Express SP1 IDE.

I think I will need to learn more about libraryes and process of their implementation before I can use these things. Any tutorials that are worth studying?

Schyfis

I'm not sure what the problem is. Have you tried the libpng binaries on this page? They have them for multiple platforms if that's what you're asking.

ReiKo90

OK, I did try to use these libraryes and here is my test code :

#SelectExpand
1#include <allegro.h> 2#include <loadpng.h> 3#include <png.h> 4#include <zlib.h> 5 6 7 8int main() { 9 10 11 allegro_init(); 12 13 set_gfx_mode(GFX_AUTODETECT,640,480,0,0); 14 set_color_depth(32); 15 16 BITMAP*alpha; 17 18 alpha = load_png("alpha.png",0); 19 20 blit(alpha,screen,0,0,200,200,256,256); 21 22 return 0; 23 24} 25END_OF_MAIN();

I get this error:

1>Compiling...
1>Main.cpp
1>Linking...
1>LINK : C:\Users\ReiKo\Documents\Visual Studio 2008\Projects\Test3\Debug\Test3.exe not found or not built by the last incremental link; performing full link
1>Main.obj : error LNK2019: unresolved external symbol _load_png referenced in function "int __cdecl _mangled_main(void)" (?_mangled_main@@YAHXZ)
1>C:\Users\ReiKo\Documents\Visual Studio 2008\Projects\Test3\Debug\Test3.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\ReiKo\Documents\Visual Studio 2008\Projects\Test3\Debug\BuildLog.htm"

I did link these libraryes:

alld.lib lpngce.lib zlibce.lib

Anything that I'm missing here? Maybe I should link loadpng .lib but I don't have any .lib files from that library. How to get them?

Sorry if questions are a bit stupid but I'm trying my best to learn.

Arthur Kalliokoski

As far as I can see, libraries with XXXXce.lib in their name are for Windows CE, running in pocket PC's and pda devices.

ReiKo90

Oh...I see, because I couldn't find libraryes for my platform as "Schyfis" said, there is only:

HP-UX
Linux
Solaris

I don't see any of them for Windows... maybe I should get Linux one and try it out? Or compile Linux one? It seems that getting this thing to work on Windows platfrom is not so easy or am I wrong?

Thanks.

Schyfis

It looks like nobody has compiled the latest version for Windows and put it online. You can either try compiling it or get the previous version (1.2.37) for Windows. I'm not sure what the changes are between the versions, the site doesn't seem to have a changelog.

Arthur Kalliokoski
Thomas Fjellstrom

Arhur, your link is broken.

Arthur Kalliokoski

Works for me ???

The stuff in the Google search box is
libpng msvc 8

Thomas Fjellstrom

Doesn't work here at all.

this however is the correct link: http://www.google.com/search?hl=en&q=libpng+msvc+8&aq=f&oq=&aqi=&fp=VEE02fthf5k

ReiKo90

Thanks on the link, currently I'm trying to compile dll's from "loadpng" library, I did include like it said "zdll.dll" and "libpng.dll" libraryes but I get this error:

1>LINK : fatal error LNK1561: entry point must be defined

I also did linked adll.lib from Allegro library.

I sense I'm close but some part of puzzle is missing ??? :)

Arthur Kalliokoski

Your link gives me a blank white screen...

Thomas Fjellstrom

you need to somehow tell MSVC that you're creating a library when you're building zlib and libpng.

Matthew Leverton

Both of those libraries come with MSVC project files that work.

Thomas Fjellstrom

Both of those libraries come with MSVC project files that work.

Not well enough it seems ;)

Arthur Kalliokoski

I've seen a thing in MSVC 8 that claims to convert MSVC 6 project files (which are listed in the libpng page), but I've never tried it.

ReiKo90

you need to somehow tell MSVC that you're creating a library when you're building zlib and libpng.

Great hint, now I'm on right track, I did sucsessfuly(altough with 5 warnings) compiled loadpng library.

Thomas Fjellstrom
ReiKo90 said:

Great hint, now I'm on right track, I did sucsessfuly(altough with 5 warnings) compiled loadpng library.

Did you use the MSVC project files that each library comes with?

ReiKo90

Did try but too much errors.

Now I did all things manually, but at the highest moment of my expectations I did get this error :( :
http://img9.imageshack.us/i/55643522.jpg/

heh man...this is so exciting :)

Thomas Fjellstrom

The error looks like it might be mixing up the runtimes or the silly xml runtime stuff is wrong.

Also, you want to set the color depth before set_gfx_mode, and check for all possible errors coming from set_gfx_mode, and load_*. And heck, and other function that can possibly fail.

ReiKo90

OK, I will try to do so...play with it for a while :) But nevertheless, I did learn something new so thanks everyone :)

Thread #601029. Printed from Allegro.cc