basic bitmap storage
Useful for comparing two JPEG images saved with a different compression ratios.

You can use these pictures for testing (use the full-size version of each):



50% quality JPEG

100% quality JPEG







link to full size 50% image

link to full size 100% image

The expected difference for these two images is 1.62125%

Chdir("|(USER_MACRO)\Rosetta\data")
File_Open("Lenna50.bmp", BROWSE)
#10 = Buf_Num				// #10 = buffer for 1st image
File_Open("Lenna100.bmp", BROWSE)
#20 = Buf_Num				// #20 = buffer for 2nd image
 
Goto_Pos(10)  				// offset to pixel data
Goto_Pos(Cur_Char + Cur_Char(1)*256)
Buf_Switch(#10)
Goto_Pos(10)
Goto_Pos(Cur_Char + Cur_Char(1)*256)
 
#15 = 0					// #15 = difference
#16 = 0					// #16 = total number of samples
While(!At_EOF) {
    #11 = Cur_Char; Char
    Buf_Switch(#20)
    #21 = Cur_Char; Char
    #15 += abs(#11-#21)
    #16++
    Buf_Switch(#10)
}
 
#19 = #15 / (#16*256/100000)
M("Sum of diff: ") NT(#15)
M("Total bytes: ") NT(#16)
M("Difference:  ") NT(#19/1000,LEFT+NOCR) M(".") NT(#19%1000,LEFT+NOCR) M("%\n")
 
Buf_Switch(#10) Buf_Quit(OK)
Buf_Switch(#20) Buf_Quit(OK)