2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
crash on pixel_to_bmap
#406386
08/18/12 23:18
08/18/12 23:18
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
Hi, Seems iam doing something horrible wrong. Why does this crash?
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: Hummel]
#406393
08/19/12 08:50
08/19/12 08:50
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
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:
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);
}
}
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: Hummel]
#406408
08/19/12 19:07
08/19/12 19:07
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
i tried this one now:
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
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
You are using pixel_to_bmap wrong. The signature is
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:
#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: MasterQ32]
#406426
08/19/12 21:34
08/19/12 21:34
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
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!
|
|
|
|