Author Topic: EVE2 Palette8 Pixels  (Read 586 times)

warriorofwire

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
EVE2 Palette8 Pixels
« on: July 01, 2018, 02:52:40 PM »
This display is awesome!  I've referenced FTDI's FT81x Series Programmers Guide and implemented a display library, asset management and lightweight display stack for RGB565.  I have a couple needs for small, high quality transparent Paletted8 bitmaps, however.  Here are the bytes that are written to memory, line:[ ] pixel: ():

[ (ff 00 00 ff) (00 ff 00 ff) (00 00 ff ff) ]    [ (ff ff ff 00) (ff ff ff 80) (ff ff ff 00) ]

This is supposed to be RGBA, 3px wide by 2px high.
Top row goes red, green, blue.
Bottom row goes transparent, halfway white transparent, transparent.

On the display there's just garbage.  What is the proper way to store in memory and display a Paletted8 bitmap on EVE2?

Code: [Select]
display_list.begin(bitmaps));
display_list.bitmap_handle(0));
display_list.bitmap_layout(BitmapFormat::Paletted8, width, height));
display_list.bitmap_size(BitmapFilter::nearest, BitmapWrap::border, BitmapWrap::border, width, height));
display_list.bitmap_source(bitmap_location));

// Alpha
display_list.blend(BlendFunction::one, BlendFunction::zero));
display_list.color_mask(0, 0, 0, 1));
display_list.palette_source(bitmap_location + 3));
display_list.vertex2ii(x, y, 0));
display_list.blend(BlendFunction::dst_alpha, BlendFunction::one_minus_dst_alpha));

// Red
display_list.color_mask(1, 0, 0, 0));
display_list.palette_source(bitmap_location));
display_list.vertex2ii(x, y, 0));

// Green
display_list.color_mask(0, 1, 0, 0));
display_list.palette_source(bitmap_location + 1));
display_list.vertex2ii(x, y, 0));

// Blue
display_list.color_mask(0, 0, 1, 0));
display_list.palette_source(bitmap_location + 2));
display_list.vertex2ii(x, y, 0));

Regular 565 2 bytes per pixel works great.  I've got animations and counters working great already, just need to figure out how to draw an RGBA8888 image :-)

I found FTDI's tool for converting PNG's to palette8.  It seems to be broken though - it won't open any png file I can find.  "invalid input file" on anything I've produced or found on the Internet.  I just need the file format and I'll make my own tool!!  What does a palette & index bytewise schema look like?
« Last Edit: July 01, 2018, 04:30:30 PM by warriorofwire »

Paul_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 299
  • Karma: 18
    • View Profile
Re: EVE2 Palette8 Pixels
« Reply #1 on: July 02, 2018, 09:32:20 AM »
Hi warriorofwire!

Iím sorry to hear about the trouble you are having with storing / displaying Paletted8 bitmaps.

FTDI has an application note for image file conversion (see page 14):

http://www.ftdichip.com/Support/Documents/AppNotes/AN_303%20FT800%20Image%20File%20Conversion.pdf

Code: [Select]
//The following code shows a PALETTED8 example for the FT81x. PALETTED8 format is supported
//indirectly in the FT81x and it is different from the PALETTED format in the FT80x. To render
//Alpha, Red, Green and Blue channels, multi-pass drawing action is required.

//addr_pal is the starting address of palette lookup table in RAM_G
//bitmap source(palette indices) is starting from address 0

dl(BITMAP_HANDLE(0))
dl(BITMAP_LAYOUT(PALETTED8, width, height))
dl(BITMAP_SIZE(NEAREST, BORDER, BORDER, width, height))

dl(BITMAP_SOURCE(0)) //bitmap source(palette indices)

dl(BEGIN(BITMAPS))
dl(BLEND_FUNC(ONE, ZERO))

//Draw Alpha channel
dl(COLOR_MASK(0,0,0,1))
dl(PALETTE_SOURCE(addr_pal+3))
dl(VERTEX2II(0, 0, 0, 0))

//Draw Red channel
dl(BLEND_FUNC(DST_ALPHA, ONE_MINUS_DST_ALPHA))
dl(COLOR_MASK(1,0,0,0))
dl(PALETTE_SOURCE (addr_pal+2))
dl(VERTEX2II (0, 0, 0, 0))

//Draw Green channel
dl(COLOR_MASK(0,1,0,0))
dl(PALETTE_SOURCE(addr_pal + 1))
dl(VERTEX2II(0, 0, 0, 0))

//Draw Blue channel
dl(COLOR_MASK(0,0,1,0))
dl(PALETTE_SOURCE(addr_pal)

Regarding the palette / index scheme of FTDI's image converter tool it may be beneficial to seek support from their support team directly.

http://www.ftdichip.com/FTContact.htm.

Hope this helps!


warriorofwire

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: EVE2 Palette8 Pixels
« Reply #2 on: July 07, 2018, 01:07:55 PM »
Oh goodness, hi Paul - thank you for your reply, I didn't have email notification set up for this thread!

I've reached out to FTDI for help.  I read that application note and the http://brtchip.com/wp-content/uploads/Support/Documentation/Programming_Guides/ICs/EVE/FT81X_Series_Programmer_Guide.pdf extensively.  It is very unclear what the "palette" schema is, and what a paletted bitmap should contain to reference that palette.

Here's the application, sorry for the poor video - I haven't implemented screen capture for video yet:  https://photos.app.goo.gl/RMbkcYQt2TUKnVTR8

The tachometer needle is a subtle asset with a blue glow that fades off over the span of a few pixels.  I'd like to retain a very high quality color gradient and use transparency.  I tried using "rgb8888" 32 bit raw bitmap and was unable to get that to work.  Any alternative ideas?  32bpp is expensive, but totally tolerable for this small, high-value asset.

By the way, I thought it was kind of funny that the coprocessor uses "degrees" for rotation when it seems most natural to use "radians" with a transformation matrix  :D

 

EVE2 TFT Module VHDL Code Support (NHD-3.5-320240FT-CSXN-CTP)

Started by bivinBoard TFTs

Replies: 0
Views: 1110
Last post March 19, 2018, 12:06:34 AM
by bivin
EVE2 Git repository proting for PIC32MZ,NHD-7.0-800480FT-CSXV-CTP

Started by mrupprathBoard TFTs

Replies: 7
Views: 2190
Last post February 14, 2018, 09:14:18 AM
by Paul_B
New Support library for Screen EVE2 NHD Playback videos

Started by lightcalamarBoard Customer Projects

Replies: 7
Views: 1878
Last post July 12, 2018, 12:43:01 PM
by lightcalamar
EVE2 Startup for 7" Display

Started by warriorofwireBoard TFTs

Replies: 2
Views: 773
Last post May 22, 2018, 01:18:23 AM
by warriorofwire
EVE2 TFT Modules VHDL Coding

Started by bivinBoard TFTs

Replies: 2
Views: 63
Last post October 03, 2018, 09:06:30 PM
by bivin