Bitmap + binary

Bitmap + binary

Postby arthursilvestre » Wed Aug 07, 2013 12:20 pm

Good morning everyone, is there any way I can create a bitmap trough of a binary code? follows a txt file with the code I have.

Link: https://mega.co.nz/#!aR8AmLJL!ce5fqX-IP ... 9pkOpO-X44
User avatar
arthursilvestre
 
Posts: 32
Joined: Thu Sep 20, 2012 7:29 pm

Re: Bitmap + binary

Postby StefanHaupt » Thu Aug 08, 2013 9:08 am

here is a sample to create small bitmaps on the fly

Code: Select all  Expand view
DWORD orange2007s[23][26]={
    { 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde, 0xfffdde},
    { 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3, 0xfff9d3},
    { 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9, 0xfff6c9},
    { 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf, 0xfff3bf},
    { 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5, 0xfff0b5},
    { 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754, 0xffd754},
    { 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f, 0xfcd34f},
    { 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b, 0xf9d04b},
    { 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47, 0xf6cd47},
    { 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43, 0xf3ca43},
    { 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f, 0xf0c73f},
    { 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a, 0xedc43a},
    { 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136, 0xebc136},
    { 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32, 0xe8be32},
    { 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e, 0xe5bb2e},
    { 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a, 0xe2b82a},
    { 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425, 0xdfb425},
    { 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121, 0xdcb121},
    { 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d, 0xd9ae1d},
    { 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19, 0xd7ab19},
    { 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815, 0xd4a815},
    { 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g, 0xd1a50g},
    { 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c, 0xcea20c}
    };

HB_FUNC( BRUSH2007ORANGES )
{
  HBITMAP hBmp;

  hBmp = CreateBitmap (26,23,1,sizeof(RGBQUAD)*8, orange2007s);
  hb_retnl( (long) hBmp);
}
 
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Bitmap + binary

Postby arthursilvestre » Thu Aug 08, 2013 12:01 pm

Good morning, thank you for attention and now I apologize for not understanding how to work right. The code that returns FastReport for me this is the link I posted in the first topic q. It generates only one line, how should I fill the vector with these my data? just a vector or a matrix of various vectors? and how to add'll call this bitmap? The function that I have to add a Bitmap to FastReport is this:

FrPrn: AddPicture ("ReportTitle1", "Name", "C: \ test.bmp", 20, 20, 200, 200) / / ( Mirror: AddPicture (cParent, cName, cFileName, Nleft, NTOP, nWidth, nHeight) )



It's just the cFileName I wish not to use. How do I assimilate the function that you pass to cFileName? that will fill a variable with the result of the function work?


Thank you for your attention.
User avatar
arthursilvestre
 
Posts: 32
Joined: Thu Sep 20, 2012 7:29 pm

Re: Bitmap + binary

Postby Antonio Linares » Thu Aug 08, 2013 6:42 pm

Arthur,

arthur.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local cFile := MemoRead( "bitmap.txt" )
   local nPos := 19
   local cBytes := ""
   local oWnd, hBitmap
   
   while nPos < Len( cFile ) - 19
      cBytes += Chr( HexToDec( SubStr( cFile, nPos, 2 ) ) )
      nPos += 2
   end      
   
   MemoWrit( "arthur.txt", cBytes )
   
   hBitmap = BuildBitmap( SubStr( cBytes, 23 ) )
   
   DEFINE WINDOW oWnd
   
   ACTIVATE WINDOW oWnd ;
      ON PAINT DrawBitmap( hDC, hBitmap, 0, 0 )
     
   MsgInfo( IsGdiObject( hBitmap ) )  
     
   DeleteObject( hBitmap )  

return nil

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

HBITMAP CreateMemBitmap3( void * cBitmap );

HB_FUNC( BUILDBITMAP )
{
   hb_retnl( ( LONG ) CreateMemBitmap3( ( void * ) hb_parc( 1 ) ) );
}  

#pragma ENDDUMP


Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bitmap + binary

Postby Antonio Linares » Thu Aug 08, 2013 8:13 pm

HBITMAP CreateMemBitmap3( void * cBitmap );

it is a new function included in FWH 13.07
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bitmap + binary

Postby Enrico Maria Giordano » Fri Aug 09, 2013 8:27 am

Antonio,

Antonio Linares wrote:
Code: Select all  Expand view
ON PAINT DrawBitmap( hDC, hBitmap, 0, 0 )


Which is better between

Code: Select all  Expand view
ON PAINT DrawBitmap( hDC, hBitmap, nTop, nLeft, nWidth, nHeight )


and

Code: Select all  Expand view
ON PAINT PalBmpDraw( hDC, 0, 0, hBitmap, , nWidth, nHeight )


?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bitmap + binary

Postby arthursilvestre » Fri Aug 09, 2013 5:54 pm

Antonio, I really liked it and this is exactly q I wish. I'm surprised, I have to confess, but would like to see if there is a possibility of doing something else. Upload this picture in FastReport. If you or someone you know I am extremely grateful. I tried but could not.

This is the syntax to add an image in FastReport:

AddPicture (cParent, cName, cFileName, Nleft, NTOP, nWidth, nHeight)

cParent = is the object where the image is affiliated (Ex: 'Page1')
cName = Name that the object of BMP will take the report
cFileName = Image path.

Here is exactly where I wanted to work. I thank you all.
User avatar
arthursilvestre
 
Posts: 32
Joined: Thu Sep 20, 2012 7:29 pm

Re: Bitmap + binary

Postby Enrico Maria Giordano » Wed Aug 14, 2013 9:55 am

Enrico Maria Giordano wrote:Antonio,

Antonio Linares wrote:
Code: Select all  Expand view
ON PAINT DrawBitmap( hDC, hBitmap, 0, 0 )


Which is better between

Code: Select all  Expand view
ON PAINT DrawBitmap( hDC, hBitmap, nTop, nLeft, nWidth, nHeight )


and

Code: Select all  Expand view
ON PAINT PalBmpDraw( hDC, 0, 0, hBitmap, , nWidth, nHeight )


?

EMG


Up! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bitmap + binary

Postby Antonio Linares » Thu Aug 15, 2013 9:40 am

Enrico,

For a simple bitmap painting use DrawBitmap().

If you need transparency, or to specify a raster operation, or to use a palette, then use PalBmpDraw(), (sort of an extended DrawBitmap())
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bitmap + binary

Postby Antonio Linares » Thu Aug 15, 2013 9:41 am

Arthur,

I don't use FastReport but I am sure that any FastReport user will be able to help you :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bitmap + binary

Postby Enrico Maria Giordano » Thu Aug 15, 2013 9:45 am

Antonio,

Antonio Linares wrote:Enrico,

For a simple bitmap painting use DrawBitmap().

If you need transparency, or to specify a raster operation, or to use a palette, then use PalBmpDraw(), (sort of an extended DrawBitmap())


So, for simple painting as in

Code: Select all  Expand view
ON PAINT DrawBitmap( hDC, hBitmap, nTop, nLeft, nWidth, nHeight )


is DrawBitmap() the best option? Thank you! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bitmap + binary

Postby Antonio Linares » Thu Aug 15, 2013 9:50 am

Enrico,

Yes, it is the simplest one :-)

In fact it uses the source code proposed by Charles Petzold in his book "Programming Windows":
ftp://ftp.charlespetzold.com/ProgWin95/CHAP19/SHOWBIT.C
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bitmap + binary

Postby Enrico Maria Giordano » Thu Aug 15, 2013 9:55 am

Antonio,

Antonio Linares wrote:Enrico,

Yes, it is the simplest one :-)

In fact it uses the source code proposed by Charles Petzold in his book "Programming Windows":
ftp://ftp.charlespetzold.com/ProgWin95/CHAP19/SHOWBIT.C


Thank you! :-)

I'm going to replace PalBmpDraw() with DrawBitmap(). :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bitmap + binary

Postby Enrico Maria Giordano » Tue Sep 10, 2013 3:34 pm

Antonio,

Enrico Maria Giordano wrote:I'm going to replace PalBmpDraw() with DrawBitmap(). :-)


FYI, I tried DrawBitmap() but the result quality is much worse than PalBmpDraw(). I reverted back to PalBmpDraw().

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bitmap + binary

Postby Antonio Linares » Tue Sep 10, 2013 7:36 pm

Enrico,

Could you provide an example to check what you comment ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 88 guests