我正在研究旧的 MS 问题并遇到了这个问题:
A pic has a bitmap assoc with it and a 256 long array of original palettes. Now we have a change list, where some old colors are mapped onto new colors. Write the code to change the original palette. Now if the original bitmap has to be changed, write the code that will scan the pic as well as the changed palette array. The code should be O(N) and not O(N^2). The struct of the original palette may be changed to accomplish this.
我无法找出确切的问题。如果有人可以说明问题和标准方法,那就太好了。非常感谢。
最佳答案
我认为这类问题应该通过与招聘人员的互动来解决。
我的方法如下:
for each *element* in *image data*
if *palette value* in *element* contains *old value*
update *palette value* with *new value*
end
process *element*
end
上面可能没有更新一些值(对于图像中不存在的一些调色板值的情况),但我认为这是处理这个问题的一种简单方法。
问候
关于c - 微软面试——图像位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13151019/