在Photoshop里一个图片一个点的颜色是FF0102,但是使用Delphi BitMap的Canvas.Pixels[]得到该点颜色居然是131583也就是201FF!!请问为什么会跟PhotoShop反过来的啊?到底哪个是标准的?我应该怎么写才能得到跟PhotoShop一样的值啊?谢谢!!!

解决方案 »

  1.   

    TColor在内存中的形式为:TColor = record
      r:Byte;
      g:Byte;
      b:Byte;
      Alpha:Byte;
    end;但在使用时要注意,如果你用
    myColor:=$AABBCC00来赋值的话,那么你得到的myColor其实相当于RGB($00,$CC,$BB)(在不考虑Alpha通道的情况下),这是因为在Delphi里保存数据是低位占第一位的,也就是说,
    const i:integer=1在内存中的形式是01 00 00 00,而不是00 00 00 01.
      

  2.   

    这跟DELPHI无关..纯粹是BMP位图的定义.PHOTOSHOP显示点颜色值顺序是R,G,B,你怎么知道它内存中颜色值不是BGR?
      

  3.   

    和BMP也无关拉,只是调用GDI如果是24位的位图,从内存中取出来是按BGR排列的TColor是直接用数字表示的,可不是记录类型,而且任何时候都不包括Alpha通道If you specify TColor as a specific 4-byte hexadecimal number instead of using the constants defined in the Graphics unit, the low three bytes represent RGB color intensities for blue, green, and red, respectively. The value $00FF0000 represents full-intensity, pure blue, $0000FF00 is pure green, and $000000FF is pure red. $00000000 is black and $00FFFFFF is white.If the highest-order byte is zero ($00), the color obtained is the closest matching color in the system palette. If the highest-order byte is one ($01), the color obtained is the closest matching color in the currently realized palette. If the highest-order byte is two ($02), the value is matched with the nearest color in the logical palette of the current device context.
      

  4.   

    和BMP也无关拉,只是调用GDI
      

  5.   

    你可以不必管他们存储的格式,用这四个Macro就可以了:由RGB分量构成颜色值:
    COLORREF RGB(
        BYTE bRed, // red component of color
        BYTE bGreen, // green component of color
        BYTE bBlue // blue component of color
       );分离各个分量:
    BYTE GetBValue(
        WORD rgb // 32-bit RGB value
       );
    BYTE GetGValue(
        WORD rgb // 32-bit RGB value
       );
    BYTE GetRValue(
        WORD rgb // 32-bit RGB value
       );