Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
18 user(s) are online (13 user(s) are browsing Forums)

Members: 0
Guests: 18

more...

Support us!

Headlines

 
  Register To Post  

bitmap object from a memory block and not from a file ?
Home away from home
Home away from home


See User information
@all

I’m having trouble creating a bitmap object when using memory data instead of loading from files.

My goal is to embed small image data directly into the main binary by converting images into raw byte arrays, rather than loading them from disk. However, no matter what I’ve tried—whether using the datatypes.library to convert PNG images to raw data or creating raw ARGB data manually—I consistently fail to create the bitmap object.

For example, this approach always works:

Image IIntuition->NewObject(BitmapClassNULL,
    
BITMAP_SourceFile"file",
    
BITMAP_SelectSourceFile"file_s",
    
BITMAP_Screen, (ULONG)pubscreen,
    
BITMAP_MaskingTRUE,
    
TAG_END);


But this one doesn’t:

Image IIntuition->NewObject(BitmapClassNULL,
    
BITMAP_BitMap, (ULONG)normalBitmap,
    
BITMAP_SelectBitMap, (DWORD)selectBitmap,
    
BITMAP_Screen, (ULONG)pubscreen,
    
BITMAP_MaskingTRUE,
    
TAG_END);


I’ve tried using datatypes.library to handle PNG data and also manually creating a bitmap from ARGB chunks, but neither worked. Is there a way to make this work without loading a bitmap file from disk?

Does anyone know a proven method to load a memory chunk directly into a BitmapClass object without relying on file-based input?

All i want it just : unsigned char cancel_s_png[844] = { 0xXX,0xXX,...etc.. }; then take this one and create bitmap image from. Of course i can go easy way, just on run create images in the T:, and then use them as sourcefiles, but while T: stand for temporary files, i really want to avoid creating any file anywhere, and just deal with standalone binary.


Edited by kas1e on 2025/5/30 8:31:50
Edited by kas1e on 2025/5/30 8:50:18
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: bitmap object from a memory block and not from a file ?
Just can't stay away
Just can't stay away


See User information
@kas1e

You can do that with the filler.image class:

Image IIntuition->NewObject(FillerClassNULL,
                              
FILLER_Screenscreen,
                              
FILLER_ImageAddressbuffer,
                              
FILLER_ImageSizebufferSize,
                              
TAG_END);


The buffer should point to a datatypes supported image format.

Go to top
Re: bitmap object from a memory block and not from a file ?
Home away from home
Home away from home


See User information
@salas00
Thanks a bunch, that it !

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: bitmap object from a memory block and not from a file ?
Home away from home
Home away from home


See User information
@salas00
But how can i specify both states (plain and selected) after i load up 2 images by filer ? Button class still want them to be as source-files, not as objects ..

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: bitmap object from a memory block and not from a file ?
Home away from home
Home away from home


See User information
@kas1eQuote:
But how can i specify both states (plain and selected) after i load up 2 images by filer ? Button class still want them to be as source-files, not as objects ..
???
button.gadget doesn't support file names, only image objects: BUTTON_RenderImage, BUTTON_SelectImage, BUTTON_DisabledImage

The bitmap.image class you previously used can use a file name (BITMAP_SourceFile), but you replace that by filler.image using pointer to the buffer and buffer size of the image data instead.

Go to top
Re: bitmap object from a memory block and not from a file ?
Home away from home
Home away from home


See User information
@joerg
Was a typo, mean bitmap.image class of course.


My problem is : a "Clicktab_closeimage" from clicktab.gadget want
a pointer to a dual state BOOPSI image, which i can create for now by bitmap class. This bitmap class have BITMAP_SourceFile and BITMAP_SelectSourceFile, which under the hood use datatypes, so simple pointing to .png files works.

Now, i need somehow create this "dual state BOOPSI image" from the memory buffers. I can use filler class of course, but i will be able only to create 2 separate image objects, which i still need to combine into the one: and there i think only about BitmapClass, which, again, want or files, or, BITMAP_BitMap and BITMAP_SelectBitMap (which of course not use datatypes and want a real bitmap and i need firstly load via datatypes by png buffers for unpacking, then extract by datatypes a bitmaps, and only then use bitmap.class to combine those 2 extracted bitmaps into one dual-state object which then use for clicktab_closeimage.

Aren't there some more easy way ? Like, dunno, use filer to load 2 separate objects, and then somehow combine them into one without involving bitmapclass (to avoid extracting of bitmaps).

My goal is with minimalistic code, have dual-close gadget be in the memory, and not rely on any external files. Maybe better to create raw files at first, and then manually create a bitmaps from (and then again bitmap class to combine into one object).


Edited by kas1e on 2025/5/31 22:26:39
Edited by kas1e on 2025/5/31 22:35:33
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: bitmap object from a memory block and not from a file ?
Home away from home
Home away from home


See User information
Currently i only found a ways to do what i need are: create 2 buffers of chars with png imags, then IDataTypes->NewDTObject with DTST_MEMORY , then , sadly, it turns out i can't use it as it for bitmapclass as it loose Alpha, so i should do some sort of converting to ARGB bitmap via pdtBlitPixelArray with necessary params, and when bitmaps are ready using them for bitmapclass, which then can use for clicktab :)


Edited by kas1e on 2025/6/1 19:26:22
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project