Re: CxImage User Input

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...

However, I was able to grab it from google cache, and I have saved them here:

http://malcom.unkmar.com/loading.html

http://malcom.unkmar.com/simplest.html

HTH

Excellent, thanks! Here we have it:

global function createDIBFromCXImage( atom image )  
  
    sequence info, pal  
    integer width, height, bitsPer, colors, headerSize  
    atom mset, memBits, memBitmapInfo, at, hdc, hDIB  
      
    mset = w32new_memset()  
      
    -- get the dib info  
    info = CXI_GetDIB( image )  
    memBits = info[1]  
    width   = info[2]  
    height  = info[3]  
    bitsPer = info[4]  
      
    -- get the palette  
    pal = CXI_GetPalette( image )  
      
    -- determine number of colors  
    colors = length( pal )  
      
    -- determine the header size  
    headerSize = SIZEOF_BITMAPINFOHEADER + (SIZEOF_RGBQUAD * colors)  
      
    -- allocate memory for DIB  
    memBitmapInfo = w32acquire_mem( mset, headerSize )  
    w32set_memory( memBitmapInfo, ID_BITMAPINFOHEADER,  
        {SIZEOF_BITMAPINFOHEADER, width, height, 1, bitsPer, 0, 0, 0, 0, colors, 0} )  
      
    -- get the address of the first rgb tuple  
    at = w32address( memBitmapInfo, bmiColors )  
  
    -- copy the pal to memory  
    for i = 1 to colors do  
  
        -- store values  
        w32store( at, rgbRed, pal[i][1] )  
        w32store( at, rgbGreen, pal[i][2] )  
        w32store( at, rgbBlue, pal[i][3] )  
        w32store( at, rgbReserved, 0 )  
  
        -- move to next quad  
        at += SIZEOF_RGBQUAD  
  
    end for  
      
    -- Get the screen's device context.  
    hdc = getDC( Screen )  
  
    -- Create the DIB.  
    hDIB = w32Func( xCreateDIBitmap, {  
            hdc,  
            w32address( memBitmapInfo, bmiHeader ),  
            CBM_INIT,  
            memBits,  
            memBitmapInfo,  
            DIB_RGB_COLORS} )  
  
    -- release the screen dc  
    releaseDC( Screen )  
  
    -- Free memory  
    w32release_mem( mset )  
  
    trackObject( {-1,kBitmapObject}, hDIB, ForProgram )  
  
    return hDIB  
end function  

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu