Login
Username:

Password:

Remember me



Lost Password?

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

Members: 2
Guests: 1

amiga, mordesku, more...

Browsing this Thread:   1 Anonymous Users



(1) 2 3 4 »


ShowPicture Image Viewer/Converter

Joined:
5/2 17:15
From California, United States
Group:
Member
Posts: 134
Offline
ShowPicture is an Image Viewer/Converter that I'm developing in conjunction with using to test and improve Picture DataTypes. ShowPicture will add to the capabilities of MultiView as far as Loading, Displaying and Saving Images using Picture DataTypes. In addition to
what MultiView can already do it will also extend this to being able to Convert images to any supported Picture DataType. But that's no all.In addition the image conversions, it will also provide the ability to Convert BitDepth for selected images types such as IFF and PNG image.

The Menu System will be similar to that of MultiView in loading and displaying images. It will consist of "Project, Window, Convert, Picture".
Under these main menus will be this: "Project>Open, Save As, Save As IFF, Save As PNG, About || Quit", Window>Maximum Size, Original Size" || "Convert>Save AS PNG, Save As BMP, Save As Gif, Save As IFF, Save As JPG, Save As TGA" || "Picture>Information, Reset Image, Fit To Window, Adjustement". The Convert Menu is new as well as Picture>Information which will provide data such as: File Name, Size in Bytes, Width x Height, BitDepth, Picture Class, and Image Type (ie. 'PNG'). Picture>Adjustments (Image Transformations) will include things like "Flip Vert/Horiz, Rotate +90, Rotate -90, Lighten, Darken, Add Glow, Background, Make Trans...etc. ShowPicture will incorporate all of the main image functions of "PNG Icon Edit". So, in addition to Converting image types and bitdepths we will also be able to edit and transform png icon images and if they are 8bit Png images especially, we could then save as IFF ILBM at 8bitplanes or simply use them to combine into a PNG Icon (.info) file.

ShowPicture allows us to open several windows with pictures simultaneously using what I call "Diplay & Forget". The menu system only applies to the Active Window and its contents. I use ReadPixelArray to get Pixel Data from the Picture DataType, then I use WritePixelArray to draw the image in the RasterPort. Afterwards I dispose of the Pixel Buffer and anything used to display the image. Then I can go on to dispaly a
new picture in a new window. The only link to the original file is the file name in the window title which will be used with filenamebuffer to find the full path of the original file so that it can be read to display information and provide a pixel buffer to save images to file.

Attach file:



png  ShowPicture2.png (210.43 KB)
6991_59f8e2489ffb9.png 800X640 px

Posted on: 10/31 13:49

Edited by miker on 2017/10/31 14:19:51
Edited by miker on 2017/10/31 14:21:05
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
5/2 17:15
From California, United States
Group:
Member
Posts: 134
Offline
If you look at the screenshot provided you will notice "Marble.png" and "Vinyl.png". Both of these images are 8bit Png. The others are 24bit Png. When I was working with ShowPicture using PNG DataType to load and display images I noticed something interesting. At first when I was displaying 32bit Png images I was using ReadPixelArray (Alpha) and in the display function WritePixelArrayAlpha. But I accidentally opened the 8bit Png file "Marble.png". It opened / displayed nicely!

Using SavePic_by_Datatype_Alpha I then saved the image data to file. Intrigued, I transferred the resulting 32bit Png called "Marble2.png" to my Windows machine and I opened it in a Paint Program. I confirmed that ShowPicture opened an 8bit Png, displayed it as 32bit on a 32bit sceenmode and saved it as a valid 32bit Png image! I didn't have to mess with Color Maps and Indexed Pixel Data! That's really cool. As far as quickly loading and displaying images the "32Bit Upscaling of 8bit Images" technique works quite well.

The best part about the previous technique is that it can also display ILBM Images of 8bitplanes and above as 32bit images on 32bit screenmodes!

Posted on: 10/31 14:34
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
5/2 17:15
From California, United States
Group:
Member
Posts: 134
Offline
It's very convenient to be able to Convert BitDepth from 8bit to 24bit or even 32bit, but goig up is easier than going down!

Converting from 32bit or 24bit down to 8bit unless the image originated as 256 colors, involves color quantizing.

Quantizing or Quantization is the process of reducing the number of used colors so that it is below 256 so they will fit on the new color palette. Color Quantizing may result in some loss of picture quality due to color reduction, but there are several Quantizing Algoriths
available. A good quantizing algorithm can perform color reduction with minimal loss of picture quality. It's simply a matter of finding a good quantizer compatible to C code. There is no plan to include a color quantizer with ShowPicture until later in development.

Other advanced imaging concepts that are needed for PNG Icon Edit, or PNG Icon Paint, or any paint program really, is that of Composite Bitmap Images and Alpha Blending.

Color Matrices can also be applied to Pixel Data for Image Transformations such as Greyscale and Sepia and several other "Effects" that can be applied to image data.

The last concept I'd like to mention is something that I have only dreamed of, but I haven't yet committed it to either Csharp or C code. I would simply call it "Color Shift" because that's what it does. If we have a png icon image such as a Dark Blue-Grey File Drawer (Ken Lester's Icons) and we display it in a window we can transform the image. Color Shift will work like this: we find the primary color in the original image, then the user selects a New Primary Color from a Color Palette. We use Color Space and Color Distance to calculate the mathematical distance between primary colors. We then apply the same color distance to an exact copy of the original Pixel Data. What results, hopefully, is an exact replica of the original image that has been transformed and color shifted. Perhaps the new primary color could be Forest Green. What starts as a Dark Blue-Grey File Drawer becomes an new one in shades of Green. It would be nice to write the function and test it with ShowPicture but currently there is no Menu System and no buttons. Perhaps I could just display the original image then impose a timer delay of .5 sec so that we can see the transformation?


********************************************************

As far as Adventures in C Programming, when comparing it to Csharp programming in Visual Studio there are many similarities in the underlying code and concepts. But the two are very different. C programming is wonderful if you don't mind making all your own tools. Anything is possible!

Posted on: 10/31 16:47
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
2008/10/11 22:43
Group:
Member
Posts: 675
Offline
Hi,

Thank you for your work on the picture Datatypes and testing with your new app.

Jeff

Posted on: 10/31 18:22
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
5/2 17:15
From California, United States
Group:
Member
Posts: 134
Offline
Thanks for the comment Jeff. I program for the sake of programming. I enjoy the challenge of it and I enjoy solving the perplexing problems that arise while writing a complex program.

Imaging programs, especially involving icon images or image conversion I suppose has been a hobby. C programming itself is a bit of a challenge as well.

The AROS Picture DataTypes could use some improvement in some areas. Some of them work just fine. But we don't have very many so when I get better at writing the datatypes I'd like to add to the collection, maybe a Targa and a Tiff datatype. Other image types can be added later if needed.

Originally I tried to avoid using Picture DataTypes to Load and Display Images, but I soon learned such as in the case of PNG images, datatypes can make life so much better and less stressful. Improving the Picture DataTypes, therefore, is necessary for my future graphics programs and for other people who might like to use the datatypes for their own purposes.

Mike R.

Posted on: 10/31 22:20
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
2012/4/16 8:41
From Brindisi (Italy)
Group:
Member
Posts: 1113
Offline
Thanks for the great work done

Posted on: 11/1 15:29
_________________
https://www.plagimusicali.net/
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
2008/6/7 13:52
Group:
Member
Posts: 2109
Offline
Thanks for the work Mike.

Posted on: 11/2 7:12
_________________
Amiga 1000, 3000D and iMica Silent and NVidia version running latest Icaros.
http://www.imica.net

Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
5/2 17:15
From California, United States
Group:
Member
Posts: 134
Offline
No problem! Improving Picture DataTypes and providing an Image Viewer/Converter for AROS is work that needs to be done, and I enjoy working with graphics programs, especially image files and icons.

I'm using my test program to improve PNG, BMP, and IFF datatypes. PNG has a problem saving to 32bit images, but I have a fix for that. BMP has several issues. I can open small images but larger images appear "tiled" or just black. I can't save images correctly. It saves a file of 0 bytes in length. In my test program I added Native methods for Load_BMP and Save_BMP. I'll use those to compare to the datatype to identify the problem areas. Likewise, the IFF datatype is incomplete. It needs a new Save_ILBM function.

I have methods to load and display and save 24bit and 32bit images, but I'm currently working on a readpixelarray_lut8 and writepixelarray_lut8 which allows me to do the same with 8bit images with colormaps. I'm almost there but I have a slight problem with the colormap for my test image. Once complete I'll be able to load, display and save 8bit images including ILBM images with 8bitplanes. Then I can move on to the Save_ILBM function that will have two subfunctions, SaveBitmapPic and SaveRGBPic. The Native Methods for these save functions in my test program will then be the basis for the IFF Picture DataType. Then IFF DataType will work!

It can't save yet but the Load_ILBM works well. I may use one of the subfunctions, ReadBitmapPic, in my test program to load and display ILBM images with less than 8 bitplanes. I wrote a Planar to Chunky conversion function a few years ago that converts planar data less than 8bpl to chunky pixel data at 8bits per pixel to display and save these ILBM images. Here is the function I wrote in Csharp using Visual Studio. I may use it in my ShowPicture program. It took two weeks of head scratching, note taking, and trial and error, but here it is:

/****************************************************************************************/
byte[] BitplanesToChunkyPixels(byte[] buffer, BMHD bmhd, int width, int bitPlanes, int bytesPerLine)
{
//Convert 4,5,6,7,8 Bitplanes to Chunky Pixel Format
//...deinterleave & convert pixeldepth as needed.
int i;
int hOffset = 0;
int bitplaneIndex = 0;
int bit = 0;
int rowSize = (bitPlanes * bytesPerLine);

byte[] colorBytes = new byte[bitPlanes]; //Block of colors
byte[] tmpBuffer = new byte[8];
byte[] bitBuffer = new byte[width];
//byte[] bitplaneBuffer = new byte[rowSize];
byte[] null8 = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };

while (hOffset < bytesPerLine) // {
//Collect 1 byte from each bitplane & add to color buffer
for (int k = 0; k < bitPlanes; k++) //Fill bitplane byte locations (Up to 58 bytes)
{
//Array.Copy(buffer, (k * bytesPerLine) + hOffset, colorBytes, 0, 1);
int lineOffset = (k * bytesPerLine) + hOffset;
//MessageBox.Show("Line Offset: " + lineOffset.ToString());
colorBytes[k] = buffer[(k * bytesPerLine) + hOffset];
//MessageBox.Show(colorBytes[k].ToString());
}
null8.CopyTo(tmpBuffer, 0);
for (int j = 0; j < 8; j++) //Fill bitplane byte locations (Up to 58 bytes)
{
bitplaneIndex = (j * bytesPerLine);
//MessageBox.Show("bitplaneIndex. " + bitplaneIndex.ToString());
byte bitmask = (byte)(1 << bit);
for (i = 0; i < 5; i++)
//for (i = 0; i < bitPlanes; i++) //Set corresponding bits in bitplane buffers
{
/* Check if the current bit of the index value is set */
if ((colorBytes[i] & (1 << j)) != 0)
{
//MessageBox.Show("Bit is Set (1).");
/* Modify the current bit in the bitplane byte to be 1 and leave the others untouched */
tmpBuffer[j] |= (byte)(1 << i);
//ILBM_SetBit(bitBuffer[0], i);
}
else
{
//MessageBox.Show("Bit is Not Set (0). ");
/* Modify the current bit in the bitplane byte to be 0 and leave the others untouched */
//bitplaneIndex (bitplane * bytesPerLine) (0,58,116,174,232,290,348,406,...) //hOffset (0-57)
//bitBuffer byte location = (bitplaneIndex + hOffset);
//ILBM_ClearBit(bitBuffer[bitplaneIndex + hOffset], 7 - i);
}
}
bit++;
//MessageBox.Show("Bit Buffer: " + bitBuffer[0]);

if (bit == 7)
{
bit = 0; /* Reset the bit counter */
//bitplaneIndex++; /* Go to the next byte in the bitplane array */
}
//MessageBox.Show(tmpBuffer[j].ToString());
}
Array.Reverse(tmpBuffer);
//MessageBox.Show("hOffset: " + hOffset.ToString());
//Array.Copy(tmpBuffer, hOffset * 8, bitBuffer, 0, 8);
Array.Copy(tmpBuffer, 0, bitBuffer, hOffset * 8, 8);
hOffset++;
}
return bitBuffer;
}

/****************************************************************************************/

Posted on: 11/2 11:58
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
5/2 17:15
From California, United States
Group:
Member
Posts: 134
Offline
I am making steady progress. I was able to load, display and save an 8bit Png image based on my test png image, Marble.png but the PLTE color palette chunk was empty. I copied the original PLTE into the new file that ShowPicture created, Marble2.png, and with the new palette the image displayed correctly. So the problem may be that I need to supply a ColorRegister as well as ULONG array of CRegs to the DataType using SetDTAttrs then it can create the PLTE correcly.

But I will set that aside for now and thoroughly test the Bitmap (BMP) DataType over the next few days. Then next week I will start writing Save_ILBM and its subfunctions SaveBitmapPic, SaveRGBPic which will become part of the ILBM (IFF) DataType Save Function. Then BMP and IFF will be complete with working Load and Save functions. Though not necessary for the IFF datatype which will save 8bit, 24bit and 32bit ILBM images, I would like to incorporate code in ShowPicture to "Save HAM8" for nostalgia reasons. That will require me to become very familiar with the HAM8 format. Who doesn't remember Jiji (or Gigi) the Cover Girl for HAM8 images back in the day? She's on the Icaros Png Picture Icon wearing her famous red scarf. I would like to include code to save directly to high quality HAM8 images, then maybe I could transfer them to my Amiga + Apollo FPGA 68080 to view them in Super AGA!
Nowadays Gigi can be found in PNG and JPG. I'd like to restore her to her HAM8 glory! But that's a possibility.

When I have completed testing and revising the picture datatypes I would like to write a Tutorial Guide about writing Picture DataTypes in PDF format "Writing Picture DataTypes for AROS" maybe with text and graphics so that others may benefit from what I have learned along the way. After completing ShowPicture I'd like to write another Tutorial Guide, "Writing Graphics Programs for AROS". And maybe a third Guide for beginners, "Sources and Resources for New AROS Programmers". Maybe that will help other people understand datatypes and graphics.

Another issue that ShowPicture may help to solve is that AROS 68k and Amiga 68k generally lack nice icons. Making nice looking 256 color icons, either ILBM with 8bitplanes or PNG with 8bits per pixel, may help with the general lack of good quality icons. My RTG Amiga with SAGA needs better, more colorful icons.


Posted on: 11/3 12:55
Transfer the post to other applications Transfer


Re: ShowPicture Image Viewer/Converter

Joined:
2006/4/7 1:34
Group:
Member
Posts: 630
Offline
@miker

I follow your progress reports for a few days now and I am very glad to read of your successful development so far. Thank you, Mike, for your efforts! Keep up the great work!

Posted on: 11/3 13:40
Transfer the post to other applications Transfer



(1) 2 3 4 »



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]


Search
Top Posters
1 paolone
paolone
4359
2 magorium
magorium
4095
3 phoenixkonsole
phoenixkonsole
3892
4 nikolaos
nikolaos
3693
5 deadwood
deadwood
2923
6 ncafferkey
ncafferkey
2646
7 mazze
mazze
2214
8 clusteruk
clusteruk
2109
9 Kalamatee
Kalamatee
2024
10 damocles
damocles
1789
© 2004-2017 AROS Exec