|
|
struct Bitmap to file? - with DataTypes |
Posted on: 2013/4/30 21:14
#1 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2012/8/14 13:51 From France
Posts: 1496
|
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
|
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 12:57
#2 |
|---|---|---|
|
Home away from home
![]() Joined:
2006/11/20 16:26 From Norway
Posts: 2955
|
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. |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 13:08
#3 |
|---|---|---|
|
Not too shy to talk
![]()
Joined:
2011/6/3 13:49 Posts: 269
|
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 |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 13:14
#4 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2012/8/14 13:51 From France
Posts: 1496
|
@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. |
|
|
_________________
http://apps.amistore.net/zTools |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 15:09
#5 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2009/5/1 18:57 From Czech Republic
Posts: 1297
|
Quote:
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 |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 15:34
#6 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2012/8/14 13:51 From France
Posts: 1496
|
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 :( |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 17:24
#7 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2009/5/1 18:57 From Czech Republic
Posts: 1297
|
Quote:
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 |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 19:25
#8 |
|---|---|---|
|
Home away from home
![]()
Joined:
2006/12/4 23:15 Posts: 2280
|
@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. |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 20:03
#9 |
|---|---|---|
|
Home away from home
![]() Joined:
2007/9/11 12:31 From Russia
Posts: 7028
|
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. |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 20:11
#10 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2012/8/14 13:51 From France
Posts: 1496
|
Yes, Kas1e,
it will be nice to have an enhancement request for that ! |
|
|
_________________
http://apps.amistore.net/zTools |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 22:15
#11 |
|---|---|---|
|
Home away from home
![]() Joined:
2007/9/11 12:31 From Russia
Posts: 7028
|
@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). |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/1 23:28
#12 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2012/8/14 13:51 From France
Posts: 1496
|
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" ? |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 3:48
#13 |
|---|---|---|
|
Amigans Defender
![]() Joined:
2006/11/26 23:16 From Canada
Posts: 986
|
Quote:
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 |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 5:54
#14 |
|---|---|---|
|
Home away from home
![]() Joined:
2007/9/11 12:31 From Russia
Posts: 7028
|
@zzd10h
Quote:
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:
Yep Quote:
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
|
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 17:37
#15 |
|---|---|---|
|
Just popping in
![]()
Joined:
2008/9/18 15:44 Posts: 106
|
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. |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 18:44
#16 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2012/8/14 13:51 From France
Posts: 1496
|
@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 ;) |
|
|
_________________
http://apps.amistore.net/zTools |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 19:31
#17 |
|---|---|---|
|
Just popping in
![]()
Joined:
2008/9/18 15:44 Posts: 106
|
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(). |
|
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 19:48
#18 |
|---|---|---|
|
Just can't stay away
![]()
Joined:
2012/8/14 13:51 From France
Posts: 1496
|
Thank you for the precisions, Wanderer.
Nice |
|
|
_________________
http://apps.amistore.net/zTools |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 19:49
#19 |
|---|---|---|
|
Amigans Defender
![]() Joined:
2006/11/26 23:16 From Canada
Posts: 986
|
Quote:
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 |
||
|
|
Re: struct Bitmap to file ? |
Posted on: 2013/5/2 21:42
#20 |
|---|---|---|
|
Just popping in
![]()
Joined:
2008/9/18 15:44 Posts: 106
|
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. |
|





