Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
panel bitmap bug #352771
01/05/11 20:22
01/05/11 20:22
Joined: Mar 2006
Posts: 2,252
Hummel Offline OP
Expert
Hummel  Offline OP
Expert

Joined: Mar 2006
Posts: 2,252
Hi,

when scaling and/or mirroring a panel with bitmap several small 'offset-bugs' seem to occur in the bitmap:



In the case of mirroring only (scale_x/y=-1) a single pixel offset appears (in mirroring direction).

Using scale_x/y=-2 gives nearly the same effect but itīs now just a half-pixel offset.

scale_x/y=(-)16 gives the same result but the panel without mirroring displays its bitmap now shifted too.

I used engine version 8.10.1

Grüße

PS: test code
Click to reveal..
Code:
#include <acknex.h>
#include <default.c>

BMAP *_bQuad="Quad.tga";

PANEL *_pQuad1=
{
	bmap=_bQuad;
	flags=SHOW;
}

PANEL *_pQuad2=
{
	bmap=_bQuad;
	flags=SHOW;
}

PANEL *_pQuad3=
{
	bmap=_bQuad;
	flags=SHOW;
}

PANEL *_pQuad4=
{
	bmap=_bQuad;
	flags=SHOW;
}

void main()
{
	fps_max=50;

	video_mode=9;
	
	vec_set(screen_color,vector(255,255,255));
	
	var _vScale=16;
	
	_pQuad1->scale_x=_vScale;
	_pQuad1->scale_y=_vScale;
	
	_pQuad1->pos_x=1*_vScale;
	_pQuad1->pos_y=1*_vScale;
	
	_pQuad2->scale_x=-_vScale;
	_pQuad2->scale_y=_vScale;
	
	_pQuad2->pos_x=18*_vScale;
	_pQuad2->pos_y=1*_vScale;
	
	_pQuad3->scale_x=_vScale;
	_pQuad3->scale_y=-_vScale;
	
	_pQuad3->pos_x=1*_vScale;
	_pQuad3->pos_y=18*_vScale;
	
	_pQuad4->scale_x=-_vScale;
	_pQuad4->scale_y=-_vScale;
	
	_pQuad4->pos_x=18*_vScale;
	_pQuad4->pos_y=18*_vScale;
}




Last edited by Hummel; 01/05/11 20:25.
Re: panel bitmap bug [Re: Hummel] #352929
01/06/11 17:19
01/06/11 17:19
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I'm afraid my best advice here is compensating the problem by painting an extra black row in your image. As you can imagine, the extra pixels that you see are drawn intentionally.

The rasterization process of graphics hardware requires pixels to be hit in the center. Otherwise, the 2D image becomes utterly distorted and you'll complain.

But when you think about the consequences of rendering from the center of the first to the center of the last pixel of a 16 pixel image, you will notice that the render length is 15 and not 16 pixels. Your image is too small and you'll complain again.

Thus, 3D engines usually render an extra pixel, getting the right image size without distortion. This is the best compromise. Our reward is that no one has complained so far. At least until now.

Hope this explains the problem.

Re: panel bitmap bug [Re: jcl] #352931
01/06/11 17:27
01/06/11 17:27
Joined: Mar 2006
Posts: 2,252
Hummel Offline OP
Expert
Hummel  Offline OP
Expert

Joined: Mar 2006
Posts: 2,252
Is there no way to implement a compensation pixel shift at least for mirroring only? (I dont really care about the scaled up versions)

Re: panel bitmap bug [Re: Hummel] #352933
01/06/11 17:31
01/06/11 17:31
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
It's not a problem of mirroring. It also happens in unmirrored images. It's only noticeable in very small images that are scaled up.

What we could theoretically do is adding a panel flag for not rendering the last pixel. You'll then get panels that are 1 pixel too small. But I do not like this solution - it's better to compensate this in the image. Or write a small function that reduces the panel size_x and size_y by 1 pixel.

Re: panel bitmap bug [Re: jcl] #352937
01/06/11 17:51
01/06/11 17:51
Joined: Mar 2006
Posts: 2,252
Hummel Offline OP
Expert
Hummel  Offline OP
Expert

Joined: Mar 2006
Posts: 2,252
Itīs also noticable in not (or just in one direction) scaled up images which are quite small like the ones you use when building a GUI and thatīs actually the situation when I noticed it.
When I want to display a window border bar using f.i. a streched 2x16 bitmap I dont care about a possible pixel shift along the stretch. But as soon as I want to use the same bitmap for the opposite border bar by using scale_x=-1; I get the pixel offset.
And since itīs the nature of this kind of bitmaps to contain important color information in just a handfull of pixels, specially in the border pixels, the visual effect can be a completely other one than the one of the opposite border.

Creating multible versions of each bitmaps seems to be the only solution...

...and that makes me sad frown

Last edited by Hummel; 01/06/11 17:52.
Re: panel bitmap bug [Re: Hummel] #352940
01/06/11 17:58
01/06/11 17:58
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
You could also make a function which creates a mirrored version of the bmap...

[as a workaround, sounds better than creating many images]

Re: panel bitmap bug [Re: Rei_Ayanami] #352941
01/06/11 18:04
01/06/11 18:04
Joined: Mar 2006
Posts: 2,252
Hummel Offline OP
Expert
Hummel  Offline OP
Expert

Joined: Mar 2006
Posts: 2,252
That is my plan but still, using a single value seems to be the smarter solution to me. Memory is not really the problem as long as I just need multible versions for the GUI but it looks like memo waste when developing a 2D game with many different tiles where you have to generate multible versions for half of the pics...

EDIT: what about a shift_x/y panel member where the user could define pixel shifts for the bitmaps of a panel on his own?
Is there a performance or technical prob implementing this?

Last edited by Hummel; 01/06/11 19:17.
Re: panel bitmap bug [Re: Hummel] #353192
01/08/11 11:12
01/08/11 11:12
Joined: Mar 2006
Posts: 2,252
Hummel Offline OP
Expert
Hummel  Offline OP
Expert

Joined: Mar 2006
Posts: 2,252
Just bumped for the case that you didnt read my 'EDIT-question'.
If you think Iīm a nagger delete this post. tongue


Moderated by  jcl, Nems, Spirit, Tobias 

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