Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
150 user(s) are online (96 user(s) are browsing Forums)

Members: 1
Guests: 149

beworld, more...

Headlines

 
  Register To Post  

(1) 2 3 »
struct Bitmap to file? - with DataTypes
Just can't stay away
Just can't stay away


See User information
Hello,
I'm looking for a function who can create an image file from a valid struct Bitmap.

Is a function of that type exists ?

Thank you, by advance, for you help



[edited thread title - Chris]


Edited by Chris on 2013/5/29 10:42:03
Go to top
Re: struct Bitmap to file ?
Home away from home
Home away from home


See User information
What program language are you using?
You need to expect more then one line of code to write a file.
If I was you lookup and read about picture datatype in autodocs.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: struct Bitmap to file ?
Not too shy to talk
Not too shy to talk


See User information
Hello

Try to use a datatype (iff one?) that have a save method

btw I found a good doc about datatype I dont remenber the url
but googlise "junod datatype"

Alain

Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
@LiveForIt
Thank for reply.
I'm using C.

For my program FastView, I rescale picture (JPG, PNG,...) by copying a Bitmap to another (with rescale).

What I would want is from a JPG (for example) to resave a new copy as JPG file.
Do you think that it's possible ?

@Thellier,
thank you,
Yes, I saw DTM_WRITE but I'm afraid that it will change the type of picture...

DTM_WRITE -- Write the selected area of the picture to a file as an
ILBM. If no area is selected, then the entire picture is
saved.

Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
Quote:

zzd10h wrote:

Yes, I saw DTM_WRITE but I'm afraid that it will change the type of picture...

DTM_WRITE -- Write the selected area of the picture to a file as an
ILBM. If no area is selected, then the entire picture is
saved.

I don't think so. DTM_WRITE is a general datatype method, so if the jpeg.datatype has this method implemented, it should save your image as JPEG. My guess at least.

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
Thank Trixie,

I have tried

SaveDTObject(dtype, NULL, NULL,"RAM:x.JPG",DTWM_RAW,TAG_DONE);

with JPG and PNG, it save well a new file (rescaled) but as ILBM format :(

Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
Quote:

I have tried

SaveDTObject(dtype, NULL, NULL, "RAM:x.JPG", DTWM_RAW, TAG_DONE);

with JPG and PNG, it save well a new file (rescaled) but as ILBM format :(

Interesting. Could the datatypes system be that useless?

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: struct Bitmap to file ?
Home away from home
Home away from home


See User information
@trixie

two things:
1.
Most picture datatypes don't implement the save method passing it to the superclass picture.datatype

So it gets saved as a ILBM



2.
If you create your data type as an picture.datatype to start with (rather than some subclass) then it'll get saved as a ILBM.

There no reason why the savers couldn't be implemented, they just haven't been so far.


Go to top
Re: struct Bitmap to file ?
Home away from home
Home away from home


See User information
As that topic about saves in datatypes brings from time to time (i remember in last year or two about 3-4 times with big-fat topics where ppls realise that there is no proper savers in most of datatypes), maybe it worth at least add BZ for enhancements ?

As i see, we have those default image datatypes in os4: bmp, gif, ilbm, jpeg, picture, png and tiff. I assume we can create just simple test case which should save an image in datatypes of our choice, and so i can add it to BZ as enhancement.

Till it not in BZ, no one will worry for sure, and topic will come up all the time.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
Yes, Kas1e,
it will be nice to have an enhancement request for that !

Go to top
Re: struct Bitmap to file ?
Home away from home
Home away from home


See User information
@zzd10h

Can you try plz from all the list of datatypes which i show, if any of them do have savers ? (i.e. test bmp, gif, ilbm, jpeg, png and tiff datatypes). Because i will go through all of them and post the same BZ, but will be not good if some of them already have savers.

And some test code also will be nice (using directly need it datatypes, without involving picture.datatype as i assume if it involved saving always will be in ILBM).

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
I will do it tomorrow but by curiosity, you said that it's a old discussion/problem therefore the datatype dev(s) must still know the problem, no ?

Nevertheless, I plan to make you a sample who :
1) load a picture by datatype
2) print his format
3) save the datatype as RAW in a new file
4) load this new file
5) print his format

Is it what you want, because I didn't understand the 2nd part of your reply "without involving picture.datatype" ?

Go to top
Re: struct Bitmap to file ?
Amigans Defender
Amigans Defender


See User information
Quote:

thellier wrote:
btw I found a good doc about datatype I dont remenber the url
but googlise "junod datatype"

That will no longer be necessary.

I have now merged that content into the AmigaOS wiki
http://wiki.amigaos.net/index.php/Datatypes_Library

I also updated some of the material for AmigaOS 4.

ExecSG Team Lead
Go to top
Re: struct Bitmap to file ?
Home away from home
Home away from home


See User information
@zzd10h
Quote:

but by curiosity, you said that it's a old discussion/problem therefore the datatype dev(s) must still know the problem, no ?


There is tons enhancement request in BZ, to works on which devs can spend next 100 years. How they will even think or remember about anything else, if it not in BZ ? Of course, savers in datatypes its something which you may think necessary, and so they all maybe too. But till its not in BZ, its all only will be talks and "yes, good to have".

Quote:

Nevertheless, I plan to make you a sample who :
1) load a picture by datatype
2) print his format
3) save the datatype as RAW in a new file
4) load this new file
5) print his format

Is it what you want ?


Yep

Quote:

because I didn't understand the 2nd part of your reply "without involving picture.datatype" ?


I am not in datatypes at all, but i about Andy's reply "If you create your data type as an picture.datatype to start with (rather than some subclass) then it'll get saved as a ILBM". So i assume from that reply there is some ways when you will always have save in ILBM does not matter what (even if you will have savers in another datatypes).


Edited by kas1e on 2013/5/2 17:12:41
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: struct Bitmap to file ?
Just popping in
Just popping in


See User information
Forget Datatypes. They work only for loading. Saving is broken on most systems, and will result in crash, broken IFF file or sonmething else unpredicatable.
Believe me, I have tried this. Even if saving works (it works with *some* datatype), it will be only IFF, and often only color index. Still, you functionality is heavily dependent on what the user has installed, and you cannot verify it for correctness.

So again, dont even try to mess with datatypes.

If you want to save jpeg, use the jpeg.library. This is relatively easy, reliable and fast, and you can make your programm complain about it if not installed.

If you use Amiblitz3, you have savers for IFF, PNG, JPEG and BMP build in. You could also write your own BMP saver, which is rather trivial, and then call an external image converting tool to produce the desired format.


Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
@Kasle

I finished to test all the formats. As suspected all formats are saved as ILBM.
BMP :
test.BMP is a picture (BMP)
new file test.BMP.BMP is a ILBM picture
DTM_WRITE KO for Datatype BMP

GIF :
test.GIF is a picture (GIF)
new file test.GIF.GIF is a ILBM picture
DTM_WRITE KO for Datatype GIF

ILBM :
test.ILBM is a picture (ILBM)
new file test.ILBM.ILBM is a ILBM picture
DTM_WRITE OK for Datatype ILBM

JPG :
test.JPG is a picture (JPEG)
new file test.JPG.JPEG is a ILBM picture
DTM_WRITE KO for Datatype JPEG

PNG :
test.PNG is a picture (PNG)
new file test.PNG.PNG is a ILBM picture
DTM_WRITE KO for Datatype PNG

TIFF :
test.TIFF is a picture (JPEG) (shown as JPEG ??? )
new file test.TIFF.JPEG is a ILBM picture
DTM_WRITE KO for Datatype JPEG

the sources (quickly wrote) are here :
http://zzd10h.amiga-ng.org/Divers/PicDType.lha

usage : PicDType file_name

file_name is open and rewritte as file_name.TYPE
(test.BMP will be saved as test.BMP.BMP)

@Wanderer
Thank you,
The results pictures are ILBM but they are fine, no color alteration for waht I see.
But your idea to use libPNG (for example) to save picture seems nice.

Is it possible to use libPNG to create picture file from a Bitmap structure ?

Would be nice to use a thing like that for my FastView program ;)

Go to top
Re: struct Bitmap to file ?
Just popping in
Just popping in


See User information
If it works for your setup, it doesnt mean it works on others setups. E.g. on OS3.x it wont save 24bit bitmaps. Under AfAOS (and AROS) it is (at least was some time ago) completely broken and crashes. There are also various pictrue.datatype implementations/updates/sidegrades etc. out there with different behaviour. So if you want to relase your program to the public, avoid datatypes for saving.

If you code in C, there are many PNG and jpeg libs out there, I would use them.
You can not save the bitmap structure as-is, in most cases you will need to create PixelArray out of the bitmap that has a well-defined pixel format, such as PFMT_ARGB, depending on what the lib needs. You typically need a RastPort on the bitmap and then call ReadPixelArray().

Go to top
Re: struct Bitmap to file ?
Just can't stay away
Just can't stay away


See User information
Thank you for the precisions, Wanderer.
Nice

Go to top
Re: struct Bitmap to file ?
Amigans Defender
Amigans Defender


See User information
Quote:

Wanderer wrote:
If it works for your setup, it doesnt mean it works on others setups. E.g. on OS3.x it wont save 24bit bitmaps. Under AfAOS (and AROS) it is (at least was some time ago) completely broken and crashes.

This is the "AmigaOS4" section so what other platforms do is not really relevant here.

Quote:
There are also various pictrue.datatype implementations/updates/sidegrades etc. out there with different behaviour. So if you want to relase your program to the public, avoid datatypes for saving.

If there are replacements for the AmigaOS 4.x picture.datatype, I'd like to work with those authors to make them obsolete.

ExecSG Team Lead
Go to top
Re: struct Bitmap to file ?
Just popping in
Just popping in


See User information
Right, if the software should be AOS4 only, the picture.datatype might have a consistent behaviour.

I haven't looked at the sub forum, my bad.

Still, the issue remains that it saves IFF-ILBM by default, and most DT implementations dont bring a saver with them.

Go to top

  Register To Post
(1) 2 3 »

 




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




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project