loadbmp 1 pixel to big

Previous topic - Next topic

racemaniac

i loaded a ping of 320x240 into the background (of a 640x480 window) with loadbmp (the png for the gp2x glbasic contest), and i noticed that the png is drawn in the rectangle x=0-320, y=0-240, which is 321 by 241 pixels...
little mistake it seems ^^

grts racemaniac

S.O.P.M.

For me it seems that the gp2x screen has in reality only 319x239 pixels because I noticed often that objects are out of screen even if they are in right size.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

racemaniac

ofcourse your coordinates only go to 239 and 319, it's because you start at 0.
0-239 = 240 numbers ^^
like an array with 240 items has it's last item at index 239 :)

Kitty Hello

I can't reproduce it. Is this problem still existing?

Schranz0r

Left upper corner is 0,0 !
Right lower corner is 319,239 (on GP2X)

0-319 = 320 Pixel
0-239 = 240 Pixel

There is nothing to big! :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Ian Price

QuoteRight upper corner is 319,239 (on GP2X)
I think you mean right lower corner there, Schranz0r. :)

But you are indeed correct and there is no obvious problems with image size in GLB or on GP2X that I've seen.
I came. I saw. I played.

Schranz0r

Ooops :)
THX for correction ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

racemaniac

i don't have a gp2x, i was testing on what was compiled on windows. so it would be a bug in the windows version, not the gp2x version.
i noticed it when making the sliding puzzle game. i drew lines on heights 59-239, and below the last line, there was still a line of the original image.
so it had to go on to pixel 240... , and if i drew a line at height 0, it also overlapped a part of the pic, so it had to start at 0.

just tested it again, and it's still there: http://users.telenet.be/racemaniac/bug.jpg
you see the code of what i did. i drew some small lines at 0 to show that the coordinates start at 0, and as you see, the lines drawn at 239 and 319 aren't on the edge of the image, it goes on to 240 and 320 :)
either that or there is some flaw with the drawline command :D, i haven't checked the exact pixel positions ^^

Moru

I did some testing too and I also see an extra (blurred) pixel line in 640x480 when loading a bitmap with 320x240 pixels. Can't do screenshots with print screen right now so can't show it but I used your program and created a picture with only diagonal lines going out to the edges. On the other side of the right and bottom lines there is an extra line with a blurred dot where my lines end.

Since I made diagonal lines I can also see that the picture isn't stretched, mabe a relative of that grab-sprite bug we were experiencing earlier?

Ian Price

If you look at the image, it's 321x241 as displayed in size. The original image was definitely 320x240, so there is indeed something amiss.

If you do this -
Code (glbasic) Select
// LoadBMP "banner.png"
LOADSPRITE "banner.png",1
SYSTEMPOINTER TRUE
DRAWSPRITE 1,0,0
DRAWLINE 0,239,320,239,RGB(255,0,0)
DRAWLINE 0,0,100,0,RGB(255,0,0)
DRAWLINE 319,0,319,240,RGB(255,0,0)
DRAWLINE 0,0,0,100,RGB(255,0,0)
SHOWSCREEN
MOUSEWAIT
it works fine, so therefore you have indeed found a bug :)

The image is being stretched by 1 pixel in each direction by the LOADBMP command.

Gernot!
I came. I saw. I played.

Kitty Hello

Aces. I'll dig into that soon.

Kitty Hello

No bug. It's just, you're pasting a surface that's smaller than the screen. The edges of the sprites you load are a mixture of the neighbored pixels, because it looks ugly otherwise when you scale them up.
So, if you hide the part that's not visible with DRAWRECT, you will see that the pixels match pretty good.