English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 21 November 2018, 20:17   #1
rcman
Long time Amiga Owner
 
rcman's Avatar
 
Join Date: Jun 2017
Location: Uxbridge Canada
Age: 56
Posts: 182
What's the rule of thumb for converting images

Hi you Coding masters,

So what is the rule of thumb when converting images. If I have a 320x200 BMP image and I use something like XNView to convert them to IFF what should I expect.

Say I want to have 16x16 blocks that I've made in windows and I want to use them on the Amiga. I used a combination of Dpaint V and PPaint but I'm finding it's not giving me what I want.

What can you tell me oh Guru of programming meditation?

RC
rcman is offline  
Old 21 November 2018, 21:29   #2
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
I'd like to know too, they always seem to be in a random palette order too!
volvo_0ne is offline  
Old 21 November 2018, 21:49   #3
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Well, what are you looking to do with them? The palette order is something you have little control over when you converting images from a colour-per-pixel format to a palette-based colour look-up format like the Amiga uses. The conversion process will end up creating a palette of the most used / most suitable colours and recreating the image with them, based on one of a number of possible algorithms.

In general though, you might get better results doing the conversion on the Amiga. I generally use PPaint for that - it will read all the main PC formats too and has several options for colour reduction that give excellent results.

If you're looking to use a particular palette, you can use PPaint to remap an image to those colours. Then, depending on how it looks, you can do some tweaking of the destination palette and repeat the mapping until you get what you need.

The palette editing functions in PPaint and DPaint let you rearrange the colours and then remap the image to suit, but I wrote a more comprehensive palette editor that can load and save palette objects, copy and past blocks of colours and so on. It's called PaletteEd, and might be useful It's AGA-only though I'm afraid...
Daedalus is offline  
Old 22 November 2018, 12:36   #4
Master484
Registered User
 
Master484's Avatar
 
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 524
Quote:
I'd like to know too, they always seem to be in a random palette order too!
I have always drawn my Amiga graphics in Windows Paint, and save them in PNG, and then convert them to Amiga IFF using XnView.

The colors of the resulting image will usually show wrong in Blitz, but a simple trick will solve this problem.

Just place your game palette colors to the upper left corner of the image you're trying to convert, like this:



Make sure that the colors appear in right order, so put your game palette color 0 first, then color 1, then color 2, and so on.

This gives the resulting IFF image the right colors.

I think XnView reads the colors from the image one pixel at a time, starting from the upper left corner and automatically creates the palette from them. The first color it sees becomes palette color 0, and the next color becomes palette color 1, and so on.

---

Another important thing is the OCS color values. On AGA each RGB component can have values from 0-255, but on OCS the RGB values have a range of 0-15.

So on when making AGA graphics the colors from Windows Paint can be used directly, and they'll show up exactly the same on an Amiga AGA screen. But on OCS the colors will not be 100% the same. Although I think that on OCS the RGB values convert automatically to closest equivalent values, so the image will show up, but the colors can be slightly off.

But there is a workaround for this problem too.

When creating your graphics on PC, just use RGB values that correspond directly to the OCS RGB values.

Here are all OCS RGB component values between 0-15 and their 0-255 color equivalents.


0 -- 0
1 -- 17
2 -- 34
3 -- 51
4 -- 68
5 -- 85
6 -- 102
7 -- 119
8 -- 136
9 -- 153
10 -- 170
11 -- 187
12 -- 204
13 -- 221
14 -- 238
15 -- 255


Draw your image using only those RGB values for all colors, and the colors should show up exactly the same on an Amiga OCS screen.
Attached Thumbnails
Click image for larger version

Name:	PaletteImgConv.png
Views:	349
Size:	2.6 KB
ID:	60899  
Master484 is offline  
Old 22 November 2018, 13:16   #5
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by Master484 View Post
I have always drawn my Amiga graphics in Windows Paint, and save them in PNG, and then convert them to Amiga IFF using XnView.
Paint? Is it really worth all that extra hassle over using, say, PPaint or DPaint? Under emulation if you don't have a suitably-equipped Amiga.

Quote:
The colors of the resulting image will usually show wrong in Blitz, but a simple trick will solve this problem.
Not just Blitz, but in general the palette will be arranged as the conversion algorithm sees fit.

Quote:
Just place your game palette colors to the upper left corner of the image you're trying to convert, like this:

Make sure that the colors appear in right order, so put your game palette color 0 first, then color 1, then color 2, and so on.

This gives the resulting IFF image the right colors.

I think XnView reads the colors from the image one pixel at a time, starting from the upper left corner and automatically creates the palette from them. The first color it sees becomes palette color 0, and the next color becomes palette color 1, and so on.
Yep, it's likely something like that alright. Just bear in mind that other conversion algorithms are likely more sophisticated and might not necessarily adhere to that scheme. Also, bear in mind that if you're only using a single sheet of images, the order might not necessarily matter. Blitz can read the palette information from an image and use it as it is. If you need to share a palette between multiple images or otherwise have control over it, remapping an image with the correct colours on the wrong palette order is trivial in DPaint or PPaint.

Quote:
Another important thing is the OCS color values. On AGA each RGB component can have values from 0-255, but on OCS the RGB values have a range of 0-15.
Indeed, forgot to mention this aspect...

Quote:
So on when making AGA graphics the colors from Windows Paint can be used directly, and they'll show up exactly the same on an Amiga AGA screen. But on OCS the colors will not be 100% the same. Although I think that on OCS the RGB values convert automatically to closest equivalent values, so the image will show up, but the colors can be slightly off.
What actually happens is that the 4 least significant bits of the value are simply ignored, leaving just the upper 4 bits to determine the level of colour.

Quote:
But there is a workaround for this problem too.

When creating your graphics on PC, just use RGB values that correspond directly to the OCS RGB values.

Here are all OCS RGB component values between 0-15 and their 0-255 color equivalents.

[...]

Draw your image using only those RGB values for all colors, and the colors should show up exactly the same on an Amiga OCS screen.
Sort of, but not quite. If you look at the upper 4 bits of the values involved, your 8-bit values start to differ from the 4-bit OCS values as you move up the scale. You'll get similar results, but they won't be 100% identical to what you intended.
Daedalus is offline  
Old 22 November 2018, 20:28   #6
Master484
Registered User
 
Master484's Avatar
 
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 524
Quote:
Paint? Is it really worth all that extra hassle over using, say, PPaint or DPaint?
Maybe not, but I have always used MS Paint for almost all gfx work, and so I just stubbornly continue using it.

Quote:
What actually happens is that the 4 least significant bits of the value are simply ignored, leaving just the upper 4 bits to determine the level of colour.
Ok, thanks for the info.

And about the color value conversions that I posted, I think they should be right.

I have checked many OCS game screenshots, opening them on Paint and checking the RGB values of different colors, and the values have always been those that are in that list.

But I quickly checked some binary values from that list, and for example OCS value 4 in binary is 0100 and the corresponding RGB value of 68 is 0100 0100. And OCS value 9 is 1001 in binary and corresponding RGB value 153 is 1001 1001. And OCS value 14 is 1110 and the corresponding RGB value 238 is 1110 1110. So everything seems to be right, although I might be wrong of course.
Master484 is offline  
Old 22 November 2018, 21:43   #7
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by Master484 View Post
Maybe not, but I have always used MS Paint for almost all gfx work, and so I just stubbornly continue using it.
Well, fair enough!

Quote:
I have checked many OCS game screenshots, opening them on Paint and checking the RGB values of different colors, and the values have always been those that are in that list.
Interesting... It would be of interest to see the values in the raw assets, rather than a screenshot from an emulator. But that seems strange as it's not how the OCS chipset really worked.

Quote:
But I quickly checked some binary values from that list, and for example OCS value 4 in binary is 0100 and the corresponding RGB value of 68 is 0100 0100. And OCS value 9 is 1001 in binary and corresponding RGB value 153 is 1001 1001. And OCS value 14 is 1110 and the corresponding RGB value 238 is 1110 1110. So everything seems to be right, although I might be wrong of course.
Yeah, it's a recommendation in the RKRMs for using 4-bit colour, that you fill the redundant bits with a copy of the relevant 4 bits to assure compatibility with both OCS and AGA chipsets, which is where that table of numbers came from. But converting the other way is a little different.
Daedalus is offline  
Old 23 November 2018, 17:26   #8
rcman
Long time Amiga Owner
 
rcman's Avatar
 
Join Date: Jun 2017
Location: Uxbridge Canada
Age: 56
Posts: 182
Hmm,

I think I'm even more confused. uhg
RC
rcman is offline  
Old 24 November 2018, 00:33   #9
bjadams
Registered User
 
Join Date: Sep 2018
Location: Chesterfield
Posts: 44
I never managed to convert a picture I reduced to 32 colours on Windows (using RGB range 0-255) to look good on OCS, because the RGB values have a range of 0-15.
When using graphic software on Windows, reducing to 32 colours gets acceptable results, that's why I am doing it this way. But I'm stuck with the palette problem.
So far I did not find a program on Windows to limit the colour palette to RGB 0-15 from the start.
bjadams is offline  
Old 12 December 2018, 21:54   #10
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Quote:
Originally Posted by bjadams View Post
I never managed to convert a picture I reduced to 32 colours on Windows (using RGB range 0-255) to look good on OCS, because the RGB values have a range of 0-15.
When using graphic software on Windows, reducing to 32 colours gets acceptable results, that's why I am doing it this way. But I'm stuck with the palette problem.
So far I did not find a program on Windows to limit the colour palette to RGB 0-15 from the start.
Maybe someone will now make one & post it on Aminet as an Amiga converter?

You never know....
volvo_0ne is offline  
Old 12 December 2018, 21:59   #11
bjadams
Registered User
 
Join Date: Sep 2018
Location: Chesterfield
Posts: 44
I wish!
bjadams is offline  
Old 12 December 2018, 22:24   #12
malko
Ex nihilo nihil
 
malko's Avatar
 
Join Date: Oct 2017
Location: CH
Posts: 4,856
Maybe of any help ? GrafX2 (from posts #71 to #79)
malko is offline  
Old 13 December 2018, 10:27   #13
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
I know it's probably not much help, but my PaletteEd program can be used for rearranging palettes, and also includes a feature for rounding a palette to 4-bit depth (OCS/ECS colour). This might be useful to use for defining a target palette with the required colour order and bit depth to which you can remap images in PPaint for example.

It is however AGA only I'm afraid...

Last edited by Daedalus; 13 December 2018 at 11:22.
Daedalus is offline  
Old 13 December 2018, 10:39   #14
bjadams
Registered User
 
Join Date: Sep 2018
Location: Chesterfield
Posts: 44
Could be helpful. thanks
bjadams is offline  
Old 13 December 2018, 11:36   #15
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
Quote:
Originally Posted by Daedalus View Post
Interesting... It would be of interest to see the values in the raw assets, rather than a screenshot from an emulator. But that seems strange as it's not how the OCS chipset really worked.
The trick is not in how OCS chipset works, but in how AGA chipset works.
When a palette entry is written to the high nibble, it is copied to the low nibble as well, thus multiplying the value by 17.
If AGA had shown OCS images differently than OCS itself did, we would know it by now, wouldn't we ?
meynaf is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving/Converting Images with Blitz fishyfish Coders. Blitz Basic 0 21 June 2013 15:57
Having trouble converting certain SPS images to ADF MethodGit project.SPS (was CAPS) 6 12 July 2011 23:03
converting .sit macintosh images to 880k W4r3DeV1L request.Other 7 19 October 2009 09:50
Rule Update BippyM MarketPlace 0 11 March 2006 16:25
Software H.I.T.L.E.R. You can’t rule the world but you can rule your software. Pyromania MarketPlace 2 08 January 2003 22:50

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:28.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.33294 seconds with 14 queries