Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / DBPro Memblock Image Issue

Author
Message
JosephB
17
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 21st Mar 2008 14:42
I have been testing making memblocks from images (JPG, PNG, and BMP images). I then make an image from that memblock and save that image to determine if there are any differences between the saved memblock image and the original image.

On one computer there are no differences between the images, however, on three other computers using the same resolution, there are the exact same differences (they are all elongated, vertically and horizontally). The result is an image of the same pixel size, but not the complete image. I have attached the code I use for the test and zipped file of the original image and the memblock created image showing the difference.

I have not yet located a discussion of this particular issue on the forum, but may not have looked far enough in the past. Please test the code and let me know your results. Is the memblock created image identical to the original or not? Also, if anyone can help me with a solution to ensure that the memblock created image will always be identical to the original image, please pass that on.

Thank you for your assistance.

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Mar 2008 15:14 Edited at: 21st Mar 2008 15:15
Some graphics cards can only handle square images, in sizes to the power of 2(32,64,128,256...) So what you have loaded and what the card creates are 2 different things. You could test this by running the same code with square images ^2, and theoretically getting success on every machine.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2008 15:20
That looks like an obscure bug to me.

What seems to be happening is that the image is being re-scaled to the next highest powers of 2 when you load the image - i.e. to 2048x1024 in your example. However, the make memblock from image command seems to be using the original image dimensions, i.e. 1280x848 in your case. Hence your image is clipped.

I'll try reproducing this with other image sizes to see if the behaviour is consistent (on my machine at least) - and on my laptop as well. Can't for the moment see why it should be different on different machines.

You can probably avoid the problem by adding the extra texture flag to the load image command.

(Second post on this today!)
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Mar 2008 15:24 Edited at: 21st Mar 2008 15:31
One thing to watch for is the actual format of the image. If you create a memblock from an image and the desktop display depth is 16-bit, then the image will be 16-bit. 16-bit is a nightmare to use compared to standard 24-bit. The image is actually loaded in the same format as the display resolution will allow, I think you might be able to get around this problem by using full screen exclusive mode with the display format specified to 24-bit. Quite easy to test that, just run the program in FS mode and see if the problem is still there.

Not sure if this is causing a problem, but it's something to watch out for when using memblock images.


less is more, but if less is more how you keeping score?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2008 15:24 Edited at: 21st Mar 2008 15:26
Quote: "Some graphics cards can only handle square images, in sizes to the power of 2(32,64,128,256...) So what you have loaded and what the card creates are 2 different things."


I don't think that is the whole story - see my previous post.

[Edit: added "my" for clarity. ]
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2008 16:13
I'm sure this is a bug. Try the following code and use any non-power of 2 image.

On my machine the image is correctly loaded and scaled to the next power of 2 (I've used a 100x200 image) as can be seen by the first saved image.

However, the memblock uses the original unscaled image width with the new scaled loaded image. Hence the clipping - and is a bug.

I don't believe this has anything to do with graphics card limitations - my card easily supports the various image sizes if I use the extra flag.

Attachments

Login to view attachments
JosephB
17
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 22nd Mar 2008 03:30
All,

Thank you very much. Using a texture flag of 1 solves the issue and ensures the memblock image is identical to the original image on other machines. Simple solution. However, I still cannot determine why there was no problem on the one computer (happens to be the machine I code on). The card on that computer is a GeForce 7600 GT (PCI Express) with 256 MB DDR3 memory. The driver is 9.1.4.7.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 22nd Mar 2008 03:58 Edited at: 22nd Mar 2008 03:59
From the documentation on load image:
A Texture Flag of zero will treat the image as a texture and load to fill a texture surface in memory. A value of one will preserve the image without adding mipmaps, scaling or filtering and so retaining its pixel perfect quality. If the value is set to two, the image is loaded as a cubemap texture, useful for shader implementation. Be aware that OS/2 bitmaps are not supported, even though they share the BMP file extension.

Leaving it off, or zero ties it to your graphics card. I think 2 would also, but I'm not sure.

Login to post a reply

Server time is: 2024-05-07 10:46:35
Your offset time is: 2024-05-07 10:46:35