c - 微软面试——图像位图

标签 c algorithm

我正在研究旧的 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/

相关文章:

c - 字符串常量和字符常量

c - inet_netof() 并返回主机字节顺序

c - C 中的标志顺序

Android 中的 connect() C 方法

algorithm - 如何在24 bpp显示器上最好地显示30+ bpp图形?

algorithm - 从 Voronoi 图到骨架

c++ - 将宏名称传递给 X-Macro 列表是否合法

algorithm - 如何获得两个图像之间的矩形差异区域?

java - 计算数组中不同元素数量的递归方法

php - 使用AJAX从MySQL数据库更新PHP页面:用于计算最近添加的数据的算法