Qbasicnews.com
April 12, 2021, 06:06:02 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Include binaries...  (Read 7812 times)
fsw
Guru
**
Posts: 251


« Reply #15 on: May 07, 2005, 07:39:05 PM »

Thanks Peter,
but you missed the whole point here.

I know how to use resources, rc, res etc. files.
Done it 1000 times, this is not the problem.

The point here is to NOT USE RESOURCES, but store the images (or whatever) into the exe and access them.
(as I said in the first post...)

This way it's harder for others to manipulate the images used by the program.
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #16 on: May 08, 2005, 04:29:49 AM »

Well, you could:

1. compile your bas file
2. get the size of the exe
3. append the data to the exe
4. open your exe as a data file in the exe itself
5. seek exesize
6. read from there
 Cheesy
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
PeterHarder
New Member

Posts: 23



WWW
« Reply #17 on: May 08, 2005, 05:52:53 AM »

Yes relsoft, that is working, just append it at the exe, I'm doing it with my Setup-Programm also, I just append the zip-file at the setup.exe.

Mostly an Icon is 766 byte, so just start at "FileLen()-766" to read the data.

Don't forget: today is mother's day (at least in Gemany)! ;-)

Kind regards

          Peter
Logged

erman freeBASIC-mailinglist: de.groups.yahoo.com/group/free-basic.
For subscribing send an empty e-mail to free-basic-subscribe@yahoogroups.de.
fsw
Guru
**
Posts: 251


« Reply #18 on: May 17, 2005, 03:10:56 PM »

Vic, can I do it that way?
Code:

dim bmpaddress as ubyte ptr = @bitmap_data(0)

dim pbfilehptr as BITMAPFILEHEADER ptr
dim pbfileh as BITMAPFILEHEADER

  'ptr to BITMAPFILEHEADER
  pbfilehptr = bmpaddress
  pbfileh = *pbfilehptr


my problem is that the address of bitmap_data(0) and pbfileh are not the same.
And because of this, while using CreateDIBitmap, it's not working.

Here the code with CreateDIBitmap:
Code:

dim bmpaddress as ubyte ptr = @bitmap_data(0)

dim pbfilehptr as BITMAPFILEHEADER ptr
dim pbfileh as BITMAPFILEHEADER

  'ptr to BITMAPFILEHEADER
  pbfilehptr = bmpaddress
  pbfileh = *pbfilehptr

dim pbinfohptr as BITMAPINFO ptr 'HEADER ptr
dim pbinfoh as BITMAPINFO 'HEADER
  'ptr to BITMAPINFO 'HEADER
'  print SizeOf(BITMAPFILEHEADER)
'  print SizeOf(BITMAPINFO)
  pbinfohptr = bmpaddress + SizeOf(BITMAPFILEHEADER)
  pbinfoh = *pbinfohptr

print @scrabble_data(0)
print pbfilehptr
print @pbfileh

dim pbits as long
dim init as long
  'pointer to bitmap data
  pbits = pbfileh.bfOffBits 'offset
  init = bmpaddress + pbits  'bitmap data

dim hdc as long
dim catchbitmap as long
  hdc=GetDC (hwnd)
'  print hdc
  catchbitmap = CreateDIBitmap (hdc, pbinfoh.bmiHeader, CBM_INIT, init, pbinfoh, DIB_RGB_COLORS)
  print catchbitmap ' should not be ZERO... but it is :(


If I can get the pointer stuff ironed out I should be able to Create a Bitmap from the data inside the exe.
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #19 on: May 17, 2005, 04:43:06 PM »

BYREF args fault again.. i hate those suckers. This test worked fine:

Code:

option explicit

#include once "win\kernel32.bi"
#include once "win\user32.bi"
#include once "win\gdi32.bi"
#include once "fblogo.bi"


declare function        WinMain     ( byval hInstance as long, _
                                      byval hPrevInstance as long, _
                                      szCmdLine as string, _
                                      byval iCmdShow as integer ) as integer
                                 
                                 
end WinMain( GetModuleHandle( null ), null, Command$, SW_NORMAL )
   
function WndProc ( byval hWnd as long, _
                   byval message as long, _
                   byval wParam as long, _
                   byval lParam as long ) as integer
    dim rct as RECT
    dim pnt as PAINTSTRUCT
    dim hDC as long
  static logoinfo as BITMAPINFO ptr
    static logodib as long
   
    WndProc = 0
   
    select case ( message )
       
        case WM_CREATE            

'' pointer to bitmap file
dim logo as BITMAPFILEHEADER ptr = @fblogo_data(0)

'' ponter to bitmap header
  logoinfo = logo + SizeOf(BITMAPFILEHEADER)

  '' create a DIB
  logodib = CreateDIBitmap( GetDC( hWnd ), byval @logoinfo->bmiHeader, _
   CBM_INIT, byval logo + logo->bfOffBits, byval logoinfo, DIB_RGB_COLORS )
 
            exit function
       
        case WM_PAINT
         
            hDC = BeginPaint( hWnd, pnt )
           
            '' load DIB to a compatible DC
            dim memDC as long
            memDC = CreateCompatibleDC( hDC )
           
            dim oldobj as long
            oldobj = SelectObject( memDC, logodib )
           
            '' blit compatible DC to this window
            BitBlt( hDC, 0, 0, logoinfo->bmiHeader.biWidth, logoinfo->bmiHeader.biHeight, _
            memDC, 0, 0, SRCCOPY )
           
            '' restore
            SelectObject( memDC, oldobj )
            DeleteDC( memDC )
           
            EndPaint( hWnd, pnt )
           
            exit function            
       
case WM_KEYDOWN
if( lobyte( wParam ) = 27 ) then
PostMessage hWnd, WM_CLOSE, 0, 0
end if
       
        case WM_DESTROY
            PostQuitMessage 0            
            exit function
    end select
   
    WndProc = DefWindowProc( hWnd, message, wParam, lParam )    
   
end function

function WinMain ( byval hInstance as long, _
                   byval hPrevInstance as long, _
                   szCmdLine as string, _
                   byval iCmdShow as integer ) as integer    
     
     dim wMsg as MSG
     dim wcls as WNDCLASS    
     dim szAppName as string
     dim hWnd as unsigned long

     
     WinMain = 0
     
     szAppName = "Test"
     
     with wcls
      .style         = CS_HREDRAW or CS_VREDRAW
      .lpfnWndProc   = @WndProc
      .cbClsExtra    = 0
      .cbWndExtra    = 0
      .hInstance     = hInstance
      .hIcon         = LoadIcon( null, byval IDI_APPLICATION )
      .hCursor       = LoadCursor( null, byval IDC_ARROW )
      .hbrBackground = GetStockObject( byval WHITE_BRUSH )
      .lpszMenuName  = null
      .lpszClassName = strptr( szAppName )
     end with
     
     
    if ( RegisterClass( wcls ) = false ) then
        exit function
    end if
   
   

    hWnd = CreateWindowEx( 0, szAppName, "Test", WS_OVERLAPPEDWINDOW, _
                          CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
                          null, null, hInstance, null )
                         

    ShowWindow   hWnd, iCmdShow
    UpdateWindow hWnd
     

    while ( GetMessage( wMsg, null, 0, 0 ) <> false )    
        TranslateMessage wMsg
        DispatchMessage  wMsg
    wend
   
   
    WinMain = wMsg.wParam

end function
Logged

fsw
Guru
**
Posts: 251


« Reply #20 on: May 17, 2005, 05:07:08 PM »

Didn't try this one:
Code:

logodib = CreateDIBitmap( GetDC( hWnd ), byval @logoinfo->bmiHeader, _
                  CBM_INIT, byval logo + logo->bfOffBits, byval logoinfo, DIB_RGB_COLORS )


No offense, but it really looks weird to me.

BTW:
What's the difference between '.' and '->' ?
Noticed that it acts differently (even in not compiling...)

Also, don't forget to add this structure to the official BI.

Code:

type BITMAPFILEHEADER field = 1
  bfType as short
  bfSize as long
  bfReserved1 as short
  bfReserved2 as short
  bfOffBits as long
End type


Thanks for you great work  :bounce:
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #21 on: May 18, 2005, 08:01:34 AM »

"." used to access elements in a type/struct while "->" is used to access elements in a pointer to type.

ie.

Code:
dim p as mytype ptr
dim a as mytype

p->x = 100

a.x = 100
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #22 on: May 18, 2005, 08:27:07 AM »

Quote from: "fsw"

Noticed that it acts differently (even in not compiling...)

Don't let the FBIde QuickRun menu deceive you...
FB must always be compiled to be able to run.
What FBIde does is compile to a temp file and run that temp file, erasing it afterwards.
Logged

Antoni
fsw
Guru
**
Posts: 251


« Reply #23 on: May 18, 2005, 01:44:43 PM »

Quote from: "relsoft"
"." used to access elements in a type/struct while "->" is used to access elements in a pointer to type.


Thank you for the explanation.
Now it's clear.

 :roll:
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!