Remember me

Lost Password?

Register now!
Main Menu
Who's Online
1 user(s) are online (1 user(s) are browsing Forum)

Members: 0
Guests: 1


Browsing this Thread:   1 Anonymous Users

« 1 (2)

Re: AROS Picture DataTypes

2017/5/2 17:15
From California, United States
Posts: 164
BTW, for whomever is interested, here are my proposed changes for the Bitmap (BMP) DataType for Save_BMP. It may be the first iteration and one or two more minor changes may need to be done to make the Save_BMP work correctly. When saving a BMP Image (Windows Bitmap File) the resulting file had 0 bytes! I commented out the suspicious code at the end of the save function that was writing an empty data buffer at the end of the save process. After this code is compiled I can test it by Loading and Saving Bitmap Files. I can then use my favorite Hex Editor to make sure the files are identical. If they aren't one more iteration of tweaks may be needed to make it save properly.

Posted on: 2017/10/28 14:49
Transfer the post to other applications Transfer

Re: AROS Picture DataTypes

2017/5/2 17:15
From California, United States
Posts: 164
Here are the proposed changes for BMP Picture DataType. Now I can focus my attention on the save function for the IFF Picture DataType. Being able to save IFF and PNG correctly is sorely needed inside Aros.

/* write image header, image has same size as screen */
if ( (bmphandle->filebufbytes -= 10) < 0 && !SaveBMP_EmptyBuf(bmphandle, 10) )
BMP_Exit(bmphandle, ERROR_NO_FREE_STORE);
return FALSE;
filebuf = bmphandle->filebufpos; /* this makes things easier */
bmphandle->filebufpos += 10;
filebuf[0] = ','; /* header ID */
filebuf[1] = filebuf[2] = 0; /* no left edge */
filebuf[3] = filebuf[4] = 0; /* no top edge */
filebuf[5] = width & 0xff;
filebuf[6] = width >> 8;
filebuf[7] = height & 0xff;
filebuf[8] = height >> 8;
filebuf[9] = numplanes & 0x07; /* set numplanes, havecolmap=0, interlaced=0 */

/* Now read the picture data from the bitplanes and write it to a chunky buffer */
/* For now, we use a full picture pixel buffer, not a single line */
widthxheight = width*height;
bmphandle->linebufsize = widthxheight;
if (! (bmphandle->linebuf = bmphandle->linebufpos = AllocMem(bmphandle->linebufsize, MEMF_ANY)) )
BMP_Exit(bmphandle, ERROR_NO_FREE_STORE);
return FALSE;
for (j=0; j {
for (i=0; i {
ret = (UBYTE)ReadPixel(&rp, i, j); /* very slow, to be changed */
*(bmphandle->linebufpos)++ = ret;
bmphandle->linebufpos = bmphandle->linebuf;

/* write the chunky buffer to file, after encoding */
if ( !bmphandle->filebufbytes-- && !SaveBMP_EmptyBuf(bmphandle, widthxheight) )
BMP_Exit(bmphandle, ERROR_NO_FREE_STORE);
return FALSE;

/* write end-of-BMP marker */
//if ( !bmphandle->filebufbytes-- && !SaveBMP_EmptyBuf(bmphandle, 1) )
//BMP_Exit(bmphandle, ERROR_NO_FREE_STORE);
//return FALSE;
//*(bmphandle->filebufpos)++ = ';';

/* flush write buffer to file and exit */
//SaveBMP_EmptyBuf(bmphandle, 0);

//D(bug("bmp.datatype/SaveBMP() --- Normal Exit\n"));
BMP_Exit(bmphandle, 0);
return TRUE;

Posted on: 2017/10/28 14:55
Transfer the post to other applications Transfer

Re: AROS Picture DataTypes

2004/4/7 4:26
Posts: 4375
Hi Miker, would you consider proposing this in the AROS developers mailing list? AROS devs do not necessarily read this forum.

Posted on: 2017/10/29 6:46
Icaros Desktop AROS distribution mantainer
Transfer the post to other applications Transfer

Re: AROS Picture DataTypes

2017/5/2 17:15
From California, United States
Posts: 164
That would be great but my Yahoo email account was rejected. Would gmail work, or MSN, hotmail? I could setup an email just for Aros if I know which one will get me in the developers mailing list. Thanks!

Paolone, I'll sort out the email list registration issue. Until then I'll keep testing and working to improve the Picture DataTypes. Lots of work to do there.


Status of Picture DataTypes:
So far I have discovered a glitch in the PNG DataType Save Function. When saving to 32bit PNG the Alpha Values are somehow inverted such as "Alpha = (255 - Alpha)" which means (0 becomes 255, 255 becomes 0). Until we find the source of the Alpha Inversion I wrote a small function to use before saving 32bit Png images using PNG DataType. It is called "Invert_Alpha". Here it is:

//Pre-modify alpha bytes using Invert_Alpha (ARGB)
RGBImage *Invert_Alpha(RGBImage *image)
int i = 0;

UBYTE *imageData = image->Data;
int imageWidth = image->Width;
int imageHeight = image->Height;

//Grab every pixel of 4 bytes then modify alpha byte.
for (i = 0; i < (imageWidth * imageHeight) * 4; i += 4)
//Invert Alpha Values for Each ScanLine Every 4 Bytes (ARGB).
imageData[i] = 255 - imageData[i]; // alpha
//data[i + 1] = 255 - data[i + 1]; // red
//data[i + 2] = 255 - data[i + 2]; // Bgreen
//data[i + 3] = 255 - data[i + 3]; // blue
image->Data = imageData;

return image;

In addition when I was testing the Windows Bitmap (BMP) DataType I wrote a Native Method for Loading and Saving BMP Images and I inserted it into my "ShowPicture" program I am using to test and improve picture datatypes. I loaded and saved BMP files to get the save function working so that I could compare it to the Save function of the BMP DataType. I was using MultiView to open the resulting BMP images, trusting that the load function of the BMP Picture DataType was working correctly. But I noticed that some of the larger BMP images I saved using my Native Method appeared totally black when using MultiView to load and display them! I thought "Wow! There must be something wrong with my Native Save Function!"

But in reality something else was happening. Later, while testing the BMP DataType I was opening and displaying several BMP images of different sizes and bitdepths using MulitView again. It opened small BMP images just fine. When opening larger images they either had a "tiled" appearance or they were completely black! So the problem isn't my Native Save Function, it's the BMP DataType!

Fortunately, the Windows Bitmap (BMP) File Format is very easy to utilize to Load and Save BMP Images, so fixing it won't be difficult. But I am also working to improve the IFF DataType by adding a save function. While working with ShowPicture to load and display IFF_ILBM images I noticed that my methods worked well with ILBM images of 8bitplanes and Above. But I had difficulting using IFF DataType to display images less than 8bitplanes. So I needed a better method. The IFF Load Function for the IFF Picture DataType used "ReadBitmapPic" for images of 8bpl and less than 8bpl and "ReadRGBPic" for images over 8bpl such as HAM8, 24bpl and 32bpl. Both of these subfunctions are contained in "Load_ILBM" with decides which function to use based on the pixel data of the image file loaded.

I will probably use "ReadBitmapPic" as a Native Method in ShowPicture but when the image data is decompressed I will instead send the Planar Pixel Data to a function I wrote for my "IFF Icon Editor" in CSharp using Visual Studio. It is P2C_LUT8 which converts the planar pixel data to a chunky pixel buffer at 8bits per pixel. The conversion from planar to chunky and bitdepth conversion happens simulataneously. The resulting 8bit Pixel Data along with the upscaled Color Map can be used later to save 8bit standard picture types such as JPG and PNG.

I will also need a "Save IFF" function for ShowPicture and to complete the IFF Picture DataType. It makes sense to use "SaveBitmapPic" for ILBM images of 8bitplanes, and "SaveRGBPic" for 24bpl and 32bpl ILBM images. Both subfunctions with be contained in "Save_ILBM" with will handle the setup process and setting up the BMHD structure then it will decide which subfunction to use based on the bitdepth of the incoming pixel data.

Posted on: 2017/10/29 8:59

Edited by miker on 2017/10/31 13:15:07
Edited by miker on 2017/10/31 13:20:20
Edited by miker on 2017/10/31 13:24:15
Edited by miker on 2017/10/31 13:24:48
Transfer the post to other applications Transfer

« 1 (2)

You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]

Top Posters
1 paolone
2 magorium
3 phoenixkonsole
4 nikolaos
5 deadwood
6 ncafferkey
7 mazze
8 clusteruk
9 Kalamatee
10 damocles
© 2004-2017 AROS Exec