Bool WREGetAndAddIconImage( BYTE *data, WResDir dir, ICONDIRENTRY *id, int ord ) { BYTE *icon; int dup; WResID *tname; WResID *rname; WResLangType lang; Bool ok; dup = FALSE; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; tname = NULL; rname = NULL; ok = ( data && dir && id && id->dwBytesInRes ); if ( ok ) { icon = (BYTE *)WREMemAlloc( id->dwBytesInRes ); ok = ( icon != NULL ); } if( ok ) { memcpy( icon, data + id->dwImageOffset, id->dwBytesInRes ); tname = WResIDFromNum( (uint_16)RT_ICON ); ok = ( tname != NULL ); } if( ok ) { rname = WResIDFromNum( ord ); ok = ( rname != NULL ); } if ( ok ) { ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0, id->dwBytesInRes, dir, &lang, &dup ); } if( ok ) { ok = WRFindAndSetData( dir, tname, rname, &lang, icon ); } if( !ok ) { if( icon != NULL ) { WREMemFree( icon ); } } if( tname != NULL ) { WREMemFree( tname ); } if( rname != NULL ) { WREMemFree( rname ); } return( ok ); }
bool WRAPI WRGetAndAddIconImage( BYTE *data, WResDir dir, ICONDIRENTRY *id, int ord ) { BYTE *icon; bool dup; WResID *tname; WResID *rname; WResLangType lang; bool ok; dup = false; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; tname = NULL; rname = NULL; ok = (data != NULL && dir != NULL && id != NULL && id->dwBytesInRes != 0); if( ok ) { icon = (BYTE *)MemAlloc( id->dwBytesInRes ); ok = (icon != NULL); } if( ok ) { memcpy( icon, data + id->dwImageOffset, id->dwBytesInRes ); tname = WResIDFromNum( RESOURCE2INT( RT_ICON ) ); ok = (tname != NULL); } if( ok ) { rname = WResIDFromNum( ord ); ok = (rname != NULL); } if( ok ) { ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0, id->dwBytesInRes, dir, &lang, &dup ); } if( ok ) { ok = WRFindAndSetData( dir, tname, rname, &lang, icon ); } if( !ok ) { if( icon != NULL ) { MemFree( icon ); } } if( tname != NULL ) { MemFree( tname ); } if( rname != NULL ) { MemFree( rname ); } return( ok ); }
Bool WREGetAndAddCursorImage( BYTE *data, WResDir dir, CURSORDIRENTRY *cd, int ord ) { BYTE *cursor; int dup; uint_32 size; WResID *tname; WResID *rname; WResLangType lang; CURSORHOTSPOT hotspot; Bool ok; dup = FALSE; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; tname = NULL; rname = NULL; ok = (data != NULL && dir != NULL && cd != NULL && cd->dwBytesInRes != 0); if ( ok ) { cursor = (BYTE *)WREMemAlloc( cd->dwBytesInRes ); ok = (cursor != NULL); } if( ok ) { memcpy( cursor, data + cd->dwImageOffset, cd->dwBytesInRes ); hotspot.xHotspot = cd->wXHotspot; hotspot.yHotspot = cd->wYHotspot; size = cd->dwBytesInRes; ok = WREAddCursorHotspot( &cursor, &size, &hotspot ); } if( ok ) { tname = WResIDFromNum( (uint_16)RT_CURSOR ); ok = (tname != NULL); } if( ok ) { rname = WResIDFromNum( ord ); ok = (rname != NULL); } if( ok ) { ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0, size, dir, &lang, &dup ); } if( ok ) { ok = WRFindAndSetData( dir, tname, rname, &lang, cursor ); } if( !ok ) { if( cursor != NULL ) { WREMemFree( cursor ); } } if( tname != NULL ) { WREMemFree( tname ); } if( rname != NULL ) { WREMemFree( rname ); } return( ok ); }
int WRLoadCursorFile( WRInfo *info ) { BYTE *data; uint_32 data_size; CURSORHEADER *ch; uint_32 chsize; RESCURSORHEADER *rch; uint_32 rchsize; WResFileID file; WResID *tname; WResID *rname; WResLangType lang; char fn[_MAX_FNAME]; int dup; int i; int ok; data = NULL; rch = NULL; dup = FALSE; file = -1; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; tname = NULL; rname = NULL; ok = ( info && info->file_name ); if( ok ) { ok = ( ( file = ResOpenFileRO( info->file_name ) ) != -1 ); } if( ok ) { ok = WRReadEntireFile( file, &data, &data_size ); } if( ok ) { ch = (CURSORHEADER *) data; chsize = sizeof(CURSORHEADER); chsize += sizeof(CURSORDIRENTRY)*(ch->cdCount-1); ok = WRCreateCursorResHeader( &rch, &rchsize, data, data_size ); } if( ok ) { ok = ( ( info->dir = WResInitDir() ) != NULL ); } if( ok ) { tname = WResIDFromNum( (uint_16)RT_GROUP_CURSOR ); ok = ( tname != NULL ); } if( ok ) { _splitpath( info->file_name, NULL, NULL, fn, NULL ); rname = WResIDFromStr( fn ); ok = ( rname != NULL ); } if ( ok ) { ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0, rchsize, info->dir, &lang, &dup ); } if( ok ) { ok = WRFindAndSetData( info->dir, tname, rname, &lang, rch ); } if( ok ) { for( i=0; ok && i<ch->cdCount ; i++ ) { ok = WRGetAndAddCursorImage( data, info->dir, &ch->cdEntries[i], i+1 ); } } if( !ok ) { if( info->dir ) { WRFreeWResDirData( info->dir ); WResFreeDir( info->dir ); info->dir = NULL; } } if( tname != NULL ) { WRMemFree( tname ); } if( rname != NULL ) { WRMemFree( rname ); } if( file != -1 ) { ResCloseFile( file ); } return( ok ); }
int WRLoadIconFile( WRInfo *info ) { BYTE *data; uint_32 data_size; ICONHEADER *pih; uint_32 pihsize; RESICONHEADER *rih; uint_32 rihsize; WResFileID file; WResID *tname; WResID *rname; WResLangType lang; char fn[_MAX_FNAME]; int dup; int i; int ok; data = NULL; rih = NULL; dup = FALSE; file = -1; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; tname = NULL; rname = NULL; ok = (info != NULL && info->file_name != NULL); if( ok ) { ok = ((file = ResOpenFileRO( info->file_name )) != -1); } if( ok ) { ok = WRReadEntireFile( file, &data, &data_size ); } if( ok ) { pih = (ICONHEADER *)data; pihsize = sizeof( ICONHEADER ); pihsize += sizeof( ICONDIRENTRY ) * (pih->idCount - 1); ok = WRCreateIconResHeader( &rih, &rihsize, data, data_size ); } if( ok ) { ok = ((info->dir = WResInitDir()) != NULL); } if( ok ) { tname = WResIDFromNum( (uint_16)RT_GROUP_ICON ); ok = (tname != NULL); } if( ok ) { _splitpath( info->file_name, NULL, NULL, fn, NULL ); rname = WResIDFromStr( fn ); ok = (rname != NULL); } if ( ok ) { ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0, rihsize, info->dir, &lang, &dup ); } if( ok ) { ok = WRFindAndSetData( info->dir, tname, rname, &lang, rih ); } if( ok ) { for( i = 0; ok && i < pih->idCount; i++ ) { ok = WRGetAndAddIconImage( data, info->dir, &pih->idEntries[i], i + 1 ); } } if( !ok ) { if( info->dir != NULL ) { WRFreeWResDirData( info->dir ); WResFreeDir( info->dir ); info->dir = NULL; } } if( data != NULL ) { WRMemFree( data ); } if( tname != NULL ) { WRMemFree( tname ); } if( rname != NULL ) { WRMemFree( rname ); } if( file != -1 ) { ResCloseFile( file ); } return( ok ); }