I've coded this up into a nice utility for screen capture.
It's called fb2bmp and I've uploaded it to the files section of
this site.
Thanks again for the help.
Larry
--- In Larry <> wrote:
>
> Thanks Charlie
> I got the BMP version coded up in about 20 minutes and it works
like a
> charm.
> The colors are off a little, but I can fix that pretty easily.
>
> Take care
> Larry
>
> Charlie Wallace wrote:
>
> > Its a fairly standard format really, its just RGB 565.
> >
> > you can save it out as a tga by just outputting a TGA header, and
> > slapping the data from the framebuffer directly afterwards, you don't
> > even have to expand it like i'm doing here, but this just makes it
> > simple, this won't compile as-is, but it ought to get you going, i
> > supplied both a BMP and TGA, these are just debug functions for me as
> > i ended up going to a different method because i ran into so many
> > structure packing problems on different compilers, so they're in a
> > controlled environment and fixed output type, i pulled out the
bits of
> > code that look like they were needed, they're from inside a class so
> > there might be some missing items, width, framebuffer pointer, but
> > easy enough to add.
> >
> > #define PACKED
> > # define GCC_PACK __attribute__((__packed__)
> >
> >
> >
> > targa version
> >
> > here's the header, made sure its set to not pad.
> >
> >
> > /// this is being phased out due to packing issues see TGAImage
instead
> >
> > typedef PACKED struct tgaImageHeader_tag {
> >
> > /* Offset Meaning */
> >
> > PACKED byte IdSize; /* 0 id field size at end of header */
> >
> > PACKED byte ColMapType; /* 1 0=>no color map, 1=>color map */
> >
> > PACKED byte TypeCode; /* 2 1=>type 1, 2=>type 2 images,... */
> >
> > PACKED word ColMapOrigin; /* 3 index of first color map entry */
> >
> > PACKED word ColMapLength; /* 5 number of entries in color map */
> >
> > PACKED byte ColMapBits; /* 7 number of bits/color map entry */
> >
> > PACKED word XOrigin; /* 8 lower left corner of image */
> >
> > PACKED word YOrigin; /* 10 lower left corner of image */
> >
> > PACKED word Width; /* 12 width of image in pixels */
> >
> > PACKED word Height; /* 14 height of image in pixels */
> >
> > PACKED byte BitsPerPixel; /* 16 see note 1: below */
> >
> > PACKED byte Descriptor; /* 17 see note 2: below */
> >
> > PACKED byte FMield[256]; /* 18 image identification field */
> >
> > /* */
> >
> > /* Note 1: The "BitsPerPixel" field depends of the type of */
> >
> > /* Targa file. For Targa type 1 images, it is the */
> >
> > /* number of bits per pixel index. For a true- */
> >
> > /* color Targa image this is 24, since pixels need */
> >
> > /* 1 byte each for r, g, and b. */
> >
> > /* Note 2: Individual bits have meaning here. For example, */
> >
> > /* toggling bit 5 flips the image upside down. */
> >
> > } GCC_PACK tgaImageHeader;
> >
> >
> >
> >
> >
> > typedef unsigned short tRGB;
> >
> > /**
> >
> > * Split a 565 RGB tuple to individual components 888
> >
> > *
> >
> > * @param rgb - 565 value to split
> >
> > * @param *r - pointer to 8 bit R storage
> >
> > * @param *g - pointer to 8 bit G storage
> >
> > * @param *b - pointer to 8 bit B storage
> >
> > *
> >
> > * @returns - none
> >
> > */
> >
> > void SplitRGB565(tRGB rgb , unsigned char *r, unsigned char *g,
> > unsigned char *b )
> >
> > {
> >
> > int ir,ig,ib;
> >
> > ir = ( rgb & ( 0x1f << 11 ) ) >> 11;
> >
> > ig = ( rgb & ( 0x3f << 5 ) ) >> 5;
> >
> > ib = rgb & 0x1f ;
> >
> > *r = ir << 3 ; *g = ig << 2 ; *b = ib << 3 ;
> >
> > return ;
> >
> > }
> >
> > inline tRGB Peek(int x,int y ) {
> >
> > return *(m_FrameBuffer + x + ( y * m_width ) );
> >
> > };
> >
> > /**
> >
> > * Save a framebuffer to 24 TGA file (currently expects 565
framebuffer)
> >
> > *
> >
> > * @param name - save filename
> >
> > * @param w - width
> >
> > * @param h - height
> >
> > * @param ptr - pointer to framebuffer to save
> >
> > *
> >
> > * @return none
> >
> > *
> >
> > * @todo convert to allow any framebuffer style
> >
> > */
> >
> > void fm_Display::WriteTGA( const char *filename, int w,int h,void
*ptr)
> >
> > {
> >
> > tgaImageHeader tgaHeader;
> >
> > int j;
> >
> > char name[512];
> >
> > fm_prolog( FM_PRI_LOW,"WriteTGA");
> >
> > fm_strcpy( name, filename );
> >
> > fm_strcat( name, ".tga");
> >
> > fm_assert( name );
> >
> > fm_assert( ptr );
> >
> > tgaHeader.IdSize = 0;
> >
> > tgaHeader.ColMapType = 0;
> >
> > tgaHeader.TypeCode = 2;
> >
> > tgaHeader.ColMapOrigin = 0;
> >
> > tgaHeader.ColMapLength = 0;
> >
> > tgaHeader.ColMapBits = 0;
> >
> > tgaHeader.XOrigin = 0;
> >
> > tgaHeader.YOrigin = 0;
> >
> > tgaHeader.Width = w;
> >
> > tgaHeader.Height = h;
> >
> > tgaHeader.BitsPerPixel = 24;
> >
> > tgaHeader.Descriptor = 1<<5;
> >
> > unsigned char *ch;
> >
> > ch = (unsigned char *) fmMALLOC( ( w * h ) * 3 );
> >
> > if( ch == FM_NULL )
> >
> > return;
> >
> > int x,y;
> >
> > FM_FILE *fp = ::fm_fopen( name, "wb" );
> >
> > if( fp ) {
> >
> > j = 0;
> >
> > for( y=0 ; y < h ; y++ )
> >
> > {
> >
> > for( x=0 ; x < w ; x++ )
> >
> > {
> >
> > unsigned char r,g,b;
> >
> > tRGB rgb ;
> >
> > rgb = Peek(x,y);
> >
> > // Read pixel and convert from 565 to 888 RGB
> >
> > SplitRGB565( rgb , &r,&g,&b );
> >
> > ch[j++] = b ;
> >
> > ch[j++] = g ;
> >
> > ch[j++] = r ;
> >
> > }
> >
> > }
> >
> > ::fm_fwrite((void*)&tgaHeader,sizeof(tgaImageHeader)-256,1,fp);
> >
> > ::fm_fwrite( &ch[0], (w*h)*3,1,fp);
> >
> > ::fm_fclose( fp );
> >
> > }
> >
> > fm_free( ch );
> >
> > }
> >
> >
////////////////////////////////////////////////////////////////////////////////////////////
> >
> > BMP version
> >
> > #define BMP_HEADER_SIZE ( 54 )
> >
> > int WriteBMP( const char *filename, int width, int height,void *data )
> >
> > {
> >
> > unsigned char *buf = (unsigned char *)data;
> >
> > char name[512];
> >
> > fm_strcpy( name, filename );
> >
> > fm_strcat( name, ".bmp");
> >
> > unsigned char h[ BMP_HEADER_SIZE ];
> >
> > FM_FILE *fp;
> >
> > int i;
> >
> > int line_bytes;
> >
> > line_bytes = (( width * 2 + 2 ) / 4 ) * 4;
> >
> > for ( i = 0; i < BMP_HEADER_SIZE; i++ ) {
> >
> > h[ i ] = 0;
> >
> > }
> >
> > h[ 0 ] = 'B';
> >
> > h[ 1 ] = 'M';
> >
> > *( int * )( h + 2 ) = ( int )( line_bytes * height * 2 +
> > BMP_HEADER_SIZE );
> >
> > *( int * )( h + 10 ) = ( int ) BMP_HEADER_SIZE;
> >
> > *( int * )( h + 14 ) = ( int ) BMP_HEADER_SIZE - 14;
> >
> > *( int * )( h + 18 ) = ( int ) width;
> >
> > *( int * )( h + 22 ) = ( int ) height;
> >
> > *( short * )( h + 26 ) = ( short ) 1;
> >
> > *( short * )( h + 28 ) = ( short ) 16;
> >
> > if (( fp = fm_fopen( name, "wb" )) == FM_NULL ) {
> >
> > return ( -1 );
> >
> > }
> >
> > fm_fwrite( h, 1, BMP_HEADER_SIZE, fp );
> >
> > for ( i = height - 1; i >= 0; i-- ) {
> >
> > unsigned char dummy[ 3 ] = { 0, 0, 0 };
> >
> > fm_fwrite( buf + width * 2 * i, 1, width * 2, fp );
> >
> > if ( line_bytes - width * 2 > 0 ) {
> >
> > fm_fwrite( dummy, 1, line_bytes - width * 2, fp );
> >
> > }
> >
> > }
> >
> > fm_fclose( fp );
> >
> > return ( 0 );
> >
> > }
> >
> > //
> >
> >
> > > I'm looking for a tool or trick to capture screen images on the
> > > ts7390 to put into a document. I can easily capture the images
from the
> > > frame buffer using the technologic frame buffer utility.
> > > However, they are in a nonstandard format.
> > > I've found stuff people have done to convert TO the framebuffer
> > > format, but so far have not seen anything for going the other
direction.
> > >
> > > Anyone have any ideas?
> > >
> > > Thanks in advance
> > > Larry
> > >
> > >
> > > ------------------------------------
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > > (Yahoo! ID required)
> > >
> > >
> > <>
> > >
> > >
> > >
> > >
> > > __________ Information from ESET NOD32 Antivirus, version of virus
> > signature database 3684 (20081211) __________
> > >
> > > The message was checked by ESET NOD32 Antivirus.
> > >
> > > http://www.eset.com <http://www.eset.com>
> > >
> > >
> > >
> >
> >
> >
>
>------------------------------------------------------------------------
> >
> >No virus found in this incoming message.
> >Checked by AVG.
> >Version: 7.5.552 / Virus Database: 270.9.16/1842 - Release Date:
12/10/2008 6:53 PM
> >
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|