I think j can be 0 at this point. But why not use bgIs24bit/bgColor/bgBlue/bgGreen here and below instead of theLine[j-1].foo?