[Nexus 6 Themes and Apps] makers_mark:
SOURCE:

MotoLogo_Injectorv.97b.bat

@echo off&setlocal enabledelayedexpansion
MODE CON:COLS=78 LINES=1024&set "vers=.97b"
title BETA BETA BETA BETA BETA Motorola Image Injector v%vers% BETA BETA BETA BETA BETA
cd /d "%~dp0"
set "file=%~1"
set /a "aspectMultiplier=100000"
set "useDefaultViewer="
set "syslog=>>"%~dp0sys\log.txt""
set "ffmpeglog="
set "validlog="
set "codeclog="
set "rawBGRDir=Raw_BGR_Files"
set "imagesDir=Images"
set "mrDir=Raw_MR_Files"
set "workHere=Projects"
set "IDfile=MoID.ID"
set "buildFile=build.ID"
set "dontShowInfo=1"
set "autoOpenFolders=1"
set "prevailExt=Png"

if not exist "%~dp0sys\" mkdir "%~dp0sys"
if exist "%~dp0sys\settings.cfg" (call :LoadSetFile)
if "%dontShowInfo%"=="1" set "validlog=>>"%~dp0sys\validation_log.txt" 2>&1" &set "codeclog=>>"%~dp0sys\codec_log.txt" 2>&1" &set "ffmpeglog=>>"%~dp0sys\ffmpeg_log.txt" 2>&1"

if exist "%~dp0sys\last_file" if "[%file%]"=="[]" call :Existing
if /i "[%file%]" equ "[$$$convert$$$]" set "file=%~2" &set "home=%~3" &call :SaveSettings &goto :ConvertFolder
if /i "[%file%]" equ "[$$notstrict$$]" set "file=%~2" &set "home=%~3" &call :SaveSettings &goto :NotStrictConvert
if "[%file%]" neq "[]" if exist "%file%" call :New &goto :Menu
call :help

:Settings
call :DrawHead
echo( ____________________________________________________________________________
echo(
if %dontShowInfo%==1 (
echo( 1 - Show Info On The Screen ^(currently data is logged^)) else (echo( 1 - Log Info To A Text File ^(currently data is shown on screen^))
)
echo(
if %autoOpenFolders%==1 (
echo( 2 - Auto Open Folders After A New File Is Created ^(currently is On^)) else (echo( 2 - Auto Open Folders After A New File Is Created ^(currently is Off^))
echo(
echo( 3 - Change Which Image Format To Use ^(currently it is %prevailExt%^)
echo(
echo( 4 - Clear Logs In Sys Folder
echo(
echo( 5 - Exit
echo(
choice /n /m " Please Select A Menu Number:" /c:12345
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if errorlevel 4 set k=4
if errorlevel 5 set k=5
if %k%==1 if %dontShowInfo%==1 (set "dontShowInfo=0") else (set "dontShowInfo=1")
if %k%==2 if %autoOpenFolders%==1 (set "autoOpenFolders=0") else (set "autoOpenFolders=1")
if %k%==3 call :ImageFormat
if %k%==4 2>nul del /q "%~dp0sys\*log*.txt
if %k%==5 goto :Menu
call :SaveSetFile
goto :Settings

:ImageFormat
call :DrawHead
echo(&echo( If you change the extension used in the program, you will no longer
echo( be able to edit older project folders that used the current image extension.
echo( You would have to switch back to what ever image format was used if you wanted
echo( to open an older project. Unless you rebuild a folder in Non Strict, which
echo( would allow you to use all different image types.
echo(&echo( Enter The Extension ^(without the "."^) That You Want To Use.
echo( Currently it is %prevailExt%
set /p prevailExt=: || set "prevailExt=Png"
call :SaveSetFile

goto :eof

:LoadSetFile
<"%~dp0sys\settings.cfg" (
set /p dontShowInfo=
set /p autoOpenFolders=
set /p prevailExt=
)
goto :eof

:SaveSetFile
>"%~dp0sys\settings.cfg" (
echo(%dontShowInfo%
echo(%autoOpenFolders%
echo(%prevailExt%
)
goto :eof

:Existing
call :LoadSettings
call :SaveSettings
if not exist "%file%" call :NotThere
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"
goto :menu
pause

:New
call :DrawHead
call :LoadNewFile
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -i "%file%" -o "%name%" -p "%home%" || (if defined "%home%" if exist "%home%\" rd /q "%home%" &call :NoLogo)
echo(&echo( MotoLogo container found, validating data...
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%file%" || (
if exist "%home%\logo.bin" (
set "file=%home%\Logo.bin"
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "!file!" || (if defined home if exist "%home%\" del /q "%home%\*.bin" &rd /q "%home%" &call :ValidFail)
) else (if defined home if exist "%home%\" del /q "%home%\*.bin" &rd /q "%home%" &call :ValidFail)
)
set "file=%home%\logo.bin"
call :SaveSettings
echo(&echo( VALIDATION SUCCESSFUL&echo(
%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
call :MakeFolders
echo(&echo( Extracting images....Please wait...&echo(
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -z -c -d -i "%file%" -o "%name%" -p "%home%\%mrDir%"
%syslog% move "%~dp0%buildFile%" "%home%\"
%syslog% move "%home%\%mrDir%\*.bgr24" "%home%\%rawBGRDir%\"
call :ffmpegit "%home%\%rawBGRDir%" "%home%\%imagesDir%"
goto :eof

:ValidFail
call :DrawHead
echo(&echo(&echo( Container Failed Validataion..
echo( Press any key to exit.
pause>nul
exit
goto :eof

:MakeFolders
2>nul mkdir "%home%\%rawBGRDir%"
2>nul mkdir "%home%\%mrDir%"
2>nul mkdir "%home%\%imagesDir%"
goto :eof

:Menu
call :DrawHead
call :DrawDetails
echo( ____________________________________________________________________________
echo(
echo( 1 - Rebuild %imagesDir% Directory ^(Strict-In Order-Resolution Checks^)
echo(
echo( 2 - Rebuild %imagesDir% Directory ^(Not Strict^)
echo(
echo( 3 - Open Current Project Folder
echo(
echo( 4 - Settings
echo(
echo( 5 - Fastboot Flash Current File
echo(
echo( 6 - Exit
echo(
choice /n /m " Please Select A Menu Number:" /c:123456
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if errorlevel 4 set k=4
if errorlevel 5 set k=5
if errorlevel 6 set k=6
if %k%==1 call :ConvertFolder
if %k%==2 call :NotStrictConvert
if %k%==3 start "" "%home%"
if %k%==4 call :Settings
if %k%==5 call :Fla****
if %k%==6 goto :finish

goto :Menu

:Fla****
call :DrawHead
call :DrawDetails
echo(&echo( Your logo is ready to be flashed.&echo( File:%file%
echo(&echo( Make sure that your device is connected and in Bootloader Mode.
echo(&echo( The following command will be issued:
echo( fastboot flash logo "%file%"
echo(&echo( Press 1 to flash the logo partition, or 2 to go back.&echo(
echo(&echo( 1 - Flash
echo(&echo( 2 - Go Back
echo(
choice /n /m " Please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 (call )
if !k!==2 goto :Menu
"%~dp0bin\fastboot.exe" flash logo "%file%" &&echo. Finished..Press any key to Reboot your device.&&pause>nul&&"%~dp0bin\fastboot.exe" reboot

goto :eof
:NotStrictConvert

call :DrawHead
echo(&echo( This will rebuild all images in the %imageDir% folder.
echo( It will rebuild in alphabetical order while disregarding
echo( original width, height, position in bin file. You can pretty
echo( much put any image format in here and get an encoded bin file.
echo( Press 1 to Continue or 2 to Go Back
echo(&echo( 1 - Continue
echo(&echo( 2 - Go Back
echo(
choice /n /m "please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 (call )
if !k!==2 goto :Menu
if exist "%home%\errors.txt" del /q "%home%\errors.txt"
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"

if defined home if exist "%home%\" rd /s /q "%home%\Not_Strict_Modified\" 2>nul
2>nul md "%home%\Not_Strict_Modified"
2>nul md "%home%\Not_Strict_Modified\%rawBGRDir%"
2>nul md "%home%\Not_Strict_Modified\%mrDir%"
set /a imageCount=0
2>nul del /q "%home%\%imagesDir%\Thumbs.db"
for /f %%a in ('dir /b /a-d-h "%home%\%imagesDir%\*.*"') do (
set /a imageCount=!imageCount!+1
echo( Converting: %%a
set "name=%%~na"
set name=!name:~0,24!

for /f "tokens=1-8* delims=," %%A in ('bin\ffmpeg -hide_banner -i "%home%\%imagesDir%\%%a" -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" 2^>^&1^|findstr /rxic:".*stream #0:0.*[0-9]x[0-9].*"') do (
echo(%%A >"%home%\imageres"
echo(%%B >>"%home%\imageres"
echo(%%C >>"%home%\imageres"
echo(%%D >>"%home%\imageres"
echo(%%E >>"%home%\imageres"
echo(%%F >>"%home%\imageres"
echo(%%G >>"%home%\imageres"
echo(%%H >>"%home%\imageres"
)
for /f "tokens=1-3 delims=x " %%I in ('type "%home%\imageres"^|findstr /rxic:".*[0-9]x[0-9].*"') do set /a width=%%I &set /a height=%%J
if not defined width echo( Error: "Width undefined in %%a">>"%home%\errors.txt"
if not defined height echo( Error: "Height undefined in %%a">>"%home%\errors.txt"

if not exist "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" echo( Error: "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" Was not created.>>"%home%\errors.txt"

echo( Encoding: !name!.bgr24
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -e -i "%home%\Not_Strict_Modified\%rawBGRDir%\!name!.bgr24" -o "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" -w !width! -h !height!
if not exist "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" echo( Error: "%home%\Not_Strict_Modified\%mrDir%\!name!.mr" Was not sucessfully encoded.>>"%home%\errors.txt"
echo(!name!?%home%\Not_Strict_Modified\%mrDir%\!name!.mr>>"%home%\Not_Strict_Modified\%buildFile%"
set check=
)
del /q "%home%\imageres"
if exist "%home%\errors.txt" call :Error
echo( Rebuilding Encoded Files...
"%~dp0bin\BuildMotoLogo.exe" <"%home%\Not_Strict_Modified\%buildFile%" -o "%home%\Not_Strict_Modified\build.bin" -n %imageCount%
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%home%\Not_Strict_Modified\build.bin" || goto :RebuildError
set "file=%home%\Not_Strict_Modified\build.bin"
set "home=%home%\Not_Strict_Modified"
call :SaveSettings

%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
echo( Validation succesful
2>nul md "%home%\%imagesDir%"
call :ffmpegit
goto :Menu

:ConvertFolder

call :DrawHead

if exist "%home%\errors.txt" del /q "%home%\errors.txt"
if not exist "%home%\%IDfile%" call :NotThere
if not exist "%home%\%buildFile%" call :NotThere
call :LoadDetails "%home%\%IDfile%"

echo(&echo( Checking Resolutions..

if defined home if exist "%home%\" rd /s /q "%home%\Modified\" 2>nul
2>nul md "%home%\Modified"
2>nul md "%home%\Modified\%rawBGRDir%"
2>nul md "%home%\Modified\%mrDir%"
for /l %%a in (1,1,%images%) do (
echo( Converting: !logoName[%%a]!
if not exist "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" (
call :DrawHead
echo(&echo( An image for !logoName[%%a]! is missing in the %imagesDir% folder.
echo(&echo( If you are trying to remove an image from you bin file, you need
echo( to rebuild the %imagesDir% folder in Non Strict Mode.
echo(&echo( Press any key to return to the menu.
pause>nul
goto :Menu
)
for /f "tokens=1-8* delims=," %%A in ('bin\ffmpeg -hide_banner -i "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" 2^>^&1^|findstr /rxic:".*stream #0:0.*[0-9]x[0-9].*"') do (
echo(%%A >"%home%\imageres"
echo(%%B >>"%home%\imageres"
echo(%%C >>"%home%\imageres"
echo(%%D >>"%home%\imageres"
echo(%%E >>"%home%\imageres"
echo(%%F >>"%home%\imageres"
echo(%%G >>"%home%\imageres"
echo(%%H >>"%home%\imageres"
)
for /f "tokens=1-3 delims=x " %%I in ('type "%home%\imageres"^|findstr /rxic:".*[0-9]x[0-9].*"') do set /a width=%%I &set /a height=%%J
if not defined width echo( Error: "Width undefined in !logoName[%%a]!.%prevailExt%">>"%home%\errors.txt"
if not defined height echo( Error: "Height undefined in !logoName[%%a]!.%prevailExt%">>"%home%\errors.txt"
if !width! neq !logoWidth[%%a]! set check=1
if !height! neq !logoHeight[%%a]! set check=1
if defined check call :Aspect !width! !height! !logoWidth[%%a]! !logoHeight[%%a]! "%home%\%imagesDir%\!logoName[%%a]!.%prevailExt%" "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" "!logoName[%%a]!"
if not exist "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" echo( Error: "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" Was not created.>>"%home%\errors.txt"

echo( Encoding: !logoName[%%a]!
%codeclog% "%~dp0bin\MotoLogoCodec.exe" -e -i "%home%\Modified\%rawBGRDir%\!logoName[%%a]!.bgr24" -o "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" -w !width! -h !height!
if not exist "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" echo( Error: "%home%\Modified\%mrDir%\!logoName[%%a]!.mr" Was not sucessfully encoded.>>"%home%\errors.txt"
echo(!logoName[%%a]!?%home%\Modified\%mrDir%\!logoName[%%a]!.mr>>"%home%\Modified\%buildFile%"
set check=
set width=
set height=
)
del /q "%home%\imageres"
if exist "%home%\errors.txt" call :Error
echo( Rebuilding Encoded Files...
"%~dp0bin\BuildMotoLogo.exe" <"%home%\Modified\%buildFile%" -o "%home%\Modified\build.bin" -n %images%
%validlog% "%~dp0bin\MotoLogoValidator.exe" -i "%home%\Modified\build.bin" || goto :RebuildError
set "file=%home%\Modified\build.bin"
set "home=%home%\Modified"
call :SaveSettings

%syslog% move "%~dp0%IDfile%" "%home%\"
call :LoadDetails "%home%\%IDfile%"
echo( Validation succesful
2>nul md "%home%\%imagesDir%"
call :ffmpegit
goto :Menu

:Aspect
set check=
set /a border=5
set /a border2=2*%border%
echo(&echo( Image: %~7
set /a newAspect=%aspectMultiplier%*%1/%2
set /a originalAspect=%aspectMultiplier%*%3/%4

echo(
echo( The resolution for %7 is different from the original image.
echo( New : %1x%2
echo( Original: %3x%4
echo(
echo( ____________________________________________________________________________
if "%originalAspect%"=="%newAspect%" (

echo(
echo( 1 - Stretch Or Shrink The Image To Fit The Original Size
echo(
echo( 2 - Do Nothing And Continue
echo(
choice /n /m "please select a menu number:" /c:12
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if !k!==1 set "videoFilters=-vf "scale=%3:%4""
if !k!==2 goto :eof
) else (
echo(
if %3 gtr %4 (echo( 1 - Resize And Crop While Keeping The Original Aspect And Size ^(Upper Image^)) else (echo( 1 - Resize And Crop While Keeping The Original Aspect And Size ^(Left Image^))
echo(
if %3 gtr %4 (echo( 2 - Stretch Or Shrink The Image To Fit The Original Size ^(Lower Image^)) else (echo( 2 - Stretch Or Shrink The Image To Fit The Original Size ^(Right Image^))
echo(
echo( 3 - Do Nothing And Continue With %1x%2 Image
echo(

if %4 lss %3 (set /a ffw=%3+2*%border%&set /a ffh=%4*2+3*%border%&set "overlay=overlay=%border%:h+%border2%") else (set /a ffw=%3*2+3*%border%&set /a ffh=%4+2*%border%&set "overlay=overlay=w+%border2%:%border%")
if %originalAspect% lss %newAspect% (set "scale=scale=-1:%4") else (set "scale=scale=%3:-1")
"%~dp0bin\ffmpeg.exe" -loglevel fatal -i "%~5" -i "%~5" -filter_complex "color=red:!ffw!x!ffh!:1[bg];[0]!scale!, crop=%3:%4[sc0];[1]scale=%3:%4[sc1];[bg][sc0]overlay=%border%:%border%[x];[x][sc1]!overlay!" -y "%home%\test.png"%ffmpeglog%
if exist "%home%\test.png" if defined useDefaultViewer (start "" "%home%\test.png") else (rundll32 "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %home%\test.png)
choice /n /m "please select a menu number:" /c:123
if errorlevel 1 set k=1
if errorlevel 2 set k=2
if errorlevel 3 set k=3
if !k!==1 (
if %originalAspect% gtr %newAspect% set "videoFilters=-vf "scale=%3:-1, crop=%3:%4""
if %originalAspect% lss %newAspect% set "videoFilters=-vf "scale=-1:%4, crop=%3:%4""
)
if !k!==2 set "videoFilters=-vf "scale=%3:%4""
if !k!==3 goto :eof
2>nul del /q "%home%\test.png"
)

set /a width=%3
set /a height=%4
%ffmpeglog% "%~dp0bin\ffmpeg.exe" %ffdebug% %ffshowb% -i "%~5" !videoFilters! -f rawvideo -vcodec rawvideo -pix_fmt bgr24 -y "%~6"
goto :eof

:RebuildError
echo( There was a problem rebuilding the images..
echo( Press any key to exit.
pause>nul
goto :Finish

:Error
call :DrawHead
echo(&type "%home%\errors.txt"
echo(&echo( Press any key to exit..
pause >nul
goto :Finish

:DrawHead
cls	echo( _________________________________________________________________________-_-
echo( Motorola Image Injector v%vers%
echo(
echo( written by Makers_Mark
echo( ____________________________________________________________________________
goto :eof

:DrawFileInfo
echo( File: %file% &echo( Size: %fileSize% Bytes ^(%megaSize%.%megaDeci% MB^)&echo( ____________________________________________________________________________
goto :eof

:DrawDetails
call :DrawFileInfo
"%~dp0bin\DrawDetails.exe" <"%home%\%IDfile%"
goto :eof

:NoLogo
call :DrawHead
echo(&echo( No Motorola Logo Images were found in the file.
echo( Press any key to exit....
pause>nul
exit

:LoadDetails
set /a images=0
for /f "tokens=1-7 delims=," %%t in ('type "%~1"') do (
set /a images+=1
set "logoName[!images!]=%%t" &set /a logoOffset[!images!]=%%y &set /a logoSize[!images!]=%%z &set /a logoSizeTotal[!images!]=%%w
set /a logoBlocks[!images!]=%%x &set /a logoWidth[!images!]=%%u &set /a logoHeight[!images!]=%%v

)
goto :eof

:dupename
if not exist "%~dp0%workhere%\!%~1!\" (goto :eof)
set /a unique=1
:dupe
if not exist "%~dp0%workhere%\!%~1!.%unique%\" (
set "%~1=!%~1!.%unique%"
goto :eof
) else (
set /a unique+=1
goto :dupe
)
goto :eof

:LoadNewFile
for %%? in ("%file%") do set /a "size=%%~z?" &set "filename=%%~nx?" &set "ext=%%~x?" &set "name=%%~n?"
set "newDir=%name%"
call :dupename "newDir"
set "home=%~dp0%workHere%\%newDir%"

2>nul mkdir "%home%"
goto :eof

:LoadSettings
<"%~dp0sys\last_file" (
set /p file=
set /p home=
set /p fileSize=
)
call :StripQuotes %file% %home%
goto :eof

:StripQuotes
set "file=%~1"
set "home=%~2"
goto :eof

:SaveSettings
for %%? in ("%file%") do set fileSize=%%~z?
set /a fileSize
set /a megaSize=%fileSize%/(1024*1024)
set /a remain=%fileSize% %% (1024*1024)
set /a megaDeci=(%remain%*1000)/(1024*1024)

>"%~dp0sys\last_file" (
echo("%file%"
echo("%home%"
echo(%fileSize%
)
goto :eof

:ffmpegit
echo( Converting Images Into %prevailExt% Images...

(for /f %%a in ('dir /b/a-d "%home%\%rawBGRDir%\*.bgr24"') do (
for /l %%? in (1, 1, %images%) do (
if "%%~na"=="!logoName[%%?]!" (
call set /a width=!logoWidth[%%?]!"
call set /a height=!logoHeight[%%?]!
)
)
"%~dp0bin\ffmpeg.exe" %ffdebug% %ffshowb% -loglevel fatal -f rawvideo -vcodec rawvideo -s !width!x!height! -pix_fmt bgr24 -i "%home%\%rawBGRDir%\%%~nxa" -y "%home%\%imagesDir%\%%~na.%prevailExt%"
))%ffmpeglog%

>"%home%\Make MotoLogo Bin From %imagesDir% Folder.bat" (
echo(@echo off
echo(cmd ^/c ^""%~dpnx0" $$$convert$$$ "%file%" "%home%"^"
echo(
)
>"%home%\Make MotoLogo Bin (Not Strict) From %imagesDir% Folder.bat" (
echo(@echo off
echo(cmd ^/c ^""%~dpnx0" $$notstrict$$ "%file%" "%home%"^"
echo(
)

if %autoOpenFolders%==1 start "" "%home%\"
goto :eof

:help
call :DrawHead
echo(&echo(
echo( You have to drag a file onto this batch file,
echo( in order to load a file into it.
echo( Press a key to close this window and exit.
pause >nul
goto :finish

:NotThere
call :Drawhead
echo(&echo(
echo( File^(s^) are missing. Reload File by dragging and dropping onto
echo( this batch file again.
echo( Press a key to close this window and exit.
pause>nul
goto :finish

:Finish
cls&exit
goto :eof

DrawDetails.c

#include <string.h>
#include <stdio.h>
#include <windows.h>

int main()
{

char *s = "," ;
char *token ;
int i , j = 1 , k , color ;
char line[80];
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
WORD originalColor;

GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
originalColor = consoleInfo.wAttributes;

printf(" ____________________________________________________________________________\n");
printf(" Image Name WxH Size+ Blocks Offset Raw Size \n");
printf(" _________________________________________________________________________-_-\n");

while(fgets(line, sizeof line, stdin) != NULL){
if (( j % 2 ) == 0) {
color = 0x0B;
} else {
color = 0xB0;
}
SetConsoleTextAttribute(hConsole, color);
token = strtok(line, s);

for ( i = 0; i < 7; i++){
if (i==0){
printf(" %2d.%-24s", j,token);
token = strtok(NULL,s);
} else if ( i == 1 ){
printf("%dx", atoi(token));
token = strtok(NULL,s);
} else if ( i == 2 ){
printf("%d\t", atoi(token));
token = strtok(NULL,s);
} else if (( i > 2) && ( i < 6 )){
printf("%d\t", atoi(token));
token = strtok(NULL,s);
} else {
printf("%-13d\r\n", atoi(token));
token = strtok(NULL,s);
}
}
j++;
}
SetConsoleTextAttribute(hConsole, originalColor);
}