fixes rgb palette
take x/y offsets into account