Amiga-Development

Please login or register.

Login with username, password and session length
Advanced search  

News:

Created for developers of all Amiga camps

Author Topic: 24Bit Image on AGA/ECS  (Read 766 times)

0 Members and 1 Guest are viewing this topic.

ALB42

  • Newbie
  • *
  • Posts: 27
    • View Profile
24Bit Image on AGA/ECS
« on: February 05, 2017, 05:44:45 PM »

Does anyone know a source or maybe even a library to show an 24bit Image on an AGA/ECS Screen (even on Workbench), so in principle to convert 24Bit to the current screen Palette + obtaining the needed pens.
Logged

SamuraiCrow

  • Administrator
  • Sr. Member
  • *****
  • Gender: Male
  • Posts: 376
  • Coolness is compiled
    • View Profile
Re: 24Bit Image on AGA/ECS
« Reply #1 on: February 07, 2017, 12:33:49 PM »

ECS is limited to 4096 colors by the Video DAC and cannot display more than that no matter what.  AGA could use HAM8 though.
Logged

ALB42

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: 24Bit Image on AGA/ECS
« Reply #2 on: February 07, 2017, 05:11:47 PM »

Thanks SamuraiCrow,
but you missunderstand my idea.
I have a 16 color screen and I have a 24bit Image and want to scale down the true color image to a 16 color palette (not predefined Palette or partly predefined like on Workbench screen).
Like MultiView or so does on Amiga when you load a truecolor PNG Image on a AGA/ECS Amiga. I guess that is already well known and solved, maybe even a Library ready to use ;-)
Logged

SamuraiCrow

  • Administrator
  • Sr. Member
  • *****
  • Gender: Male
  • Posts: 376
  • Coolness is compiled
    • View Profile
Re: 24Bit Image on AGA/ECS
« Reply #3 on: February 08, 2017, 05:35:42 AM »

If you want to use datatypes to do so, you can import a true color image, but it will lose detail or color or both.  It requires AmigaOS 3 to use and won't work on earlier versions and also is included with AROS.
Logged

ALB42

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: 24Bit Image on AGA/ECS
« Reply #4 on: February 08, 2017, 08:26:44 PM »

For AROS/MorphOS/OS4 its not a problem ;) there I have CGFX.

About Datatypes I also thought, but I don't have a file ;) only a memory area with RGB Values.

render.library seems to offer something like that.
Logged

magorium

  • Full Member
  • ***
  • Posts: 200
  • Programming is an art form that fights back
    • View Profile
Re: 24Bit Image on AGA/ECS
« Reply #5 on: February 11, 2017, 12:15:39 AM »

About Datatypes I also thought, but I don't have a file ;) only a memory area with RGB Values.
hmz, i was going to suggest using datatypes as well.

Quote
render.library seems to offer something like that.
I got myself a 5 minute break, and what am i doing... telling that FPC also offer something similar  :P

(Please check good for typo's/obvious errors as i only had remote compilation available, in theory below code should work)

Code: [Select]
program test;

{$MODE OBJFPC}{$H+}

Uses
  Classes, FPImage, FPDitherer, FPReadBMP, FPWriteBMP;

var
  WBPalette : TFPPalette;
  // Default 4 'color' workbench (colors are a bit off, sue me :-p ).
  WBColors  : Array[0..3] of TFPColor =
  (
    ( red: $9595; Green: $9595; Blue: $9595; Alpha: $FFFF ),
    ( red: $0000; Green: $0000; Blue: $0000; Alpha: $FFFF ),
    ( red: $FFFF; Green: $FFFF; Blue: $FFFF; Alpha: $FFFF ),
    ( red: $3B3B; Green: $6767; Blue: $A2A2; Alpha: $FFFF )
  );

  i,x,y     : integer;
  SrcBitmap : TFPMemoryImage;
  DstBitmap : TFPMemoryImage;
  FS_Dither : TFPFloydSteinbergDitherer;
  Writer    : TFPWriterBMP;
begin
  // Create palette based on WB colors;
  WBPalette := TFPPalette.Create(0);

  for i := Low(WBColors) to High(WBColors)
    do WBPalette.Add(WBColors[i]);

  WriteLn('After adding colours the palette contains ', WBPalette.Count, ' colors');
  for i := 0 to Pred(WBPalette.Count) do
  begin
    WriteLn('color[',i,'] = ', HexStr(WBPalette[i].Red,4), ' ', HexStr(WBPalette[i].Green,4), ' ', HexStr(WBPalette[i].blue,4), ' ', HexStr(WBPalette[i].alpha,4));
  end;

  // init
  SrcBitmap := TFPMemoryImage.Create(0,0);
  DstBitmap := TFPMemoryImage.Create(0,0);
  Writer    := TFPWriterBMP.Create;

  // 'simulate' raw data
  SrcBitmap.LoadFromFile('Test.bmp');

  // create and apply dithering
  FS_Dither := TFPFloydSteinbergDitherer.Create(WBPalette);
  FS_Dither.Dither(SrcBitmap, DstBitmap);
  // 'simulate' display (replace with drawing into window)
  Writer.BitsPerPixel := 4;
  DstBitmap.SaveToFile('Test.Out.bmp', Writer);

  // example:
  for y := 0 to Pred(DstBitmap.Height) do
  begin
    for x := 0 to Pred(DstBitmap.Width) do
    begin
      // print pallette index numbers, otherwise for rgb values use colors proprty.
      // WriteLn('Pixel(x,y) = ', DstBitmap.Pixels[x,y]);
      Write(' ', DstBitmap.Pixels[x,y]);
    end; 
    WriteLn;
  end;

  // Done
  FS_Dither.Free;
  Writer.Free;
  DstBitmap.Free;
  SrcBitmap.Free;

  WBPalette.Free;
end.
Dunno how practical fpimage would be on classic though, as it is a bit memory hungry. In theory it works good.

Would probably also work nicer if you could use LCL :)
Logged