21 lines
478 B
Text
21 lines
478 B
Text
// Convert RGB image to grayscale (8 bit/pixel)
|
|
// #10 = buffer that contains image data
|
|
// On return:
|
|
// #20 = buffer for the new grayscale image
|
|
|
|
:RGB_TO_GRAYSCALE:
|
|
File_Open("|(VEDIT_TEMP)\gray.data", OVERWRITE+NOEVENT+NOMSG)
|
|
#20 = Buf_Num
|
|
BOF
|
|
Del_Char(ALL)
|
|
Buf_Switch(#10)
|
|
Repeat(File_Size/3) {
|
|
#9 = Cur_Char() * 2126
|
|
#9 += Cur_Char(1) * 7152
|
|
#9 += Cur_Char(2) * 722
|
|
Char(3)
|
|
Buf_Switch(#20)
|
|
Ins_Char(#9 / 10000)
|
|
Buf_Switch(#10)
|
|
}
|
|
Return
|