Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
crash on pixel_to_bmap #406386
08/18/12 23:18
08/18/12 23:18
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Hi,
Seems iam doing something horrible wrong.

Why does this crash?

Code:
SelectionTexture = bmap_createblack(width, height, 8888);
	var LMode = bmap_lock(SelectionTexture, 0);	
	var LPixel = pixel_for_vec(vector(255, 0, 0), 128, LMode);
	pixel_to_bmap(AX, AY, SelectionTexture, LPixel);
	bmap_unlock(SelectionTexture);



Last edited by Rackscha; 08/18/12 23:19.

MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: crash on pixel_to_bmap [Re: Rackscha] #406387
08/18/12 23:22
08/18/12 23:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Is AX/ AY valid?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: crash on pixel_to_bmap [Re: Superku] #406392
08/19/12 08:14
08/19/12 08:14
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
Doesn't GS always use values in the range [0..100] for alpha? (which is kinda stupid if you ask me)

Re: crash on pixel_to_bmap [Re: Hummel] #406393
08/19/12 08:50
08/19/12 08:50
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
First, have you checked if SelectionTexture is != NULL? Second, are width and height valid (>0)? Third, is LMode valid? Fourth, alpha has to be between 0 and 100, as Hummel said. I guess you want a half translucent pixel, so use 50. Fifth, are AX and AY inside the bounds of the bitmap, as Superku said?

I would at least try the following to make sure that it doesn't crash the program:

Code:
BMAP* SelectionTexture = bmap_createblack(width, height, 8888);
if (SelectionTexture != NULL)
{
    var LMode = bmap_lock(SelectionTexture, 0);
    if (LMode > 0)
    {
        var LPixel = pixel_for_vec(vector(255, 0, 0), 50, LMode);
        pixel_to_bmap(AX, AY, SelectionTexture, LPixel);
        
        bmap_unlock(SelectionTexture);
    }
}



Originally Posted By: Hummel
Doesn't GS always use values in the range [0..100] for alpha? (which is kinda stupid if you ask me)
I find it very intuitive, if you ask me, since 100% means "fully opaque"... in all Corel products, it is vice versa, they take 100% for "completely translucent" and whenever I type in alpha values, I mess up with those. Anyways, it would be cooler if Gamestudio would take 0...1, because it reensembles the alpha blending factor. But that would be counter intuitive again and everything would have to be changed, too.

Last edited by HeelX; 08/19/12 08:51.
Re: crash on pixel_to_bmap [Re: HeelX] #406397
08/19/12 09:24
08/19/12 09:24
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
Of course percent measuring is more intuitive but since it's not used for the colors too it appears somewhat inconsistent imo. Also, using the range [0..255] makes it easier to tweak the amount of transparency. The ranges [0..1] or [0..100] only make sense if you work with floating point values.

Re: crash on pixel_to_bmap [Re: Hummel] #406408
08/19/12 19:07
08/19/12 19:07
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
i tried this one now:

Code:
if ((SelectionTexture != NULL) && (bmap_width(SelectionTexture) > 0) && (bmap_height(SelectionTexture) > 0))
	{
		var LMode = bmap_lock(SelectionTexture, 0);
		if (LMode > 0)
		{
			var LPixel = pixel_for_vec(vector(255, 0, 0), 50, LMode);
			pixel_to_bmap(0, 0, SelectionTexture, LPixel);
			
			bmap_unlock(SelectionTexture);
		}
	}



and it crashed


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: crash on pixel_to_bmap [Re: Rackscha] #406419
08/19/12 20:37
08/19/12 20:37
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
You are using pixel_to_bmap wrong. The signature is
Code:
pixel_to_bmap(BMAP* bmap,var x,var y,var pixel);



You are passing the coordinates first, then the bitmap, then the pixel value. Look at my code:

Code:
#include <acknex.h>
#include <default.c>

int main ()
{
    wait(3);
    
    int bmapWidth = 8;
    int bmapHeight = 8;

    // drawing a red bitmap with a half-yellow pixel
    BMAP* b = bmap_createblack(bmapWidth, bmapHeight, 8888);
    if (b != NULL)
    {
        bmap_fill(b, vector(0,0,255), 100);
    
        var f = bmap_lock(b, 0);
        if (f > 0)
        {
            var p = pixel_for_vec(vector(0, 255, 255), 50, f);
            pixel_to_bmap(b, 3, 3, p);
            bmap_unlock(b);
        }
        else
            error("hehehe... there is a bitmap - but it can't be locked. Hihihi.");
    }
    else
        error("no bitmap was created. Damn.");
        
    float bmapScale = 32.0;
        
    if (b != NULL)
    {
        PANEL* p = pan_create("", 0);
        if (p != NULL)
        {
            p->bmap = b;
            p->size_x = b->width;
            p->size_y = b->height;
            p->scale_x = p->scale_y = bmapScale;
            
            p->flags = SHOW;
        }
        else
            error("no panel was created. Damn.");
    }
    else
        error("no bitmap is there.... grrrr!");
}



Last edited by HeelX; 08/19/12 21:33.
Re: crash on pixel_to_bmap [Re: HeelX] #406422
08/19/12 21:00
08/19/12 21:00
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
this is no bug, just create some bitmap which can handle alpha values (bmap_createblack(..., 8888 or 32););


Visit my site: www.masterq32.de
Re: crash on pixel_to_bmap [Re: MasterQ32] #406426
08/19/12 21:34
08/19/12 21:34
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: MasterQ32
this is no bug, just create some bitmap which can handle alpha values (bmap_createblack(..., 8888 or 32););
Thanks - and I'm sorry. I adjusted my code above and moved the post into the Lite-C forum. D'oh!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1