Storage access: files or memory?

This forum is dedicated to those who wish to suggest new features.
Questo forum è dedicato a chi desidera suggerire nuove feature.
Ce forum est dédié à ceux qui souhaitent suggérer de nouvelles fonctionnalités.
spotlessmind1975
Site Admin
Posts: 204
Joined: Fri Oct 06, 2023 8:25 pm

Re: Storage access: files or memory?

Post by spotlessmind1975 »

Hi ldir_hector, no problem, actually happy to read you!
ldir_hector wrote: Sat Mar 01, 2025 8:28 pm I tried this DLOAD source with a png file of 16*16 pixels only containing red.
If the image contains only red pixels, ugBASIC will consider red as the background color, and therefore will set the background color of the entire screen as such.If, on the contrary, the image does not have only red pixels (as in the case of token_red.png in the examples) then the fact that only red pixels appear depends on the fact that ugBASIC takes red as the prevailing value, and considers it as the "background color".

The solution is to suggest to ugBASIC not to do any special reasoning, using the EXACT keyword. In this case, it will not reorder the palette by quantity of pixels of that color but will consider the colors "as is". Therefore, since the first pixel is a black pixel, the background will be black and the image will be displayed.

This is the code I suggest to use (it is yours with the EXACT keyword added):

Code: Select all

    BITMAP ENABLE(320,200,4)
    CLS
    STORAGE "disco" AS "disk1"
        IMAGE "token_red.png" AS "tokenred" EXACT
    ENDSTORAGE    
    CLS
    tokenImage := NEW IMAGE(16, 16)
    DLOAD "tokenred" TO VARPTR(tokenImage)
    PUT IMAGE tokenImage AT 32, 32

This is the result:
Image

Thank you!
Post Reply