title: MapRGB in sdl with cairo , the color is error
body: <p>i use SDL2 with MapRGB to let win10 window transparent, and use cairo to draw something, but the color is not true, like that cairo use rgb(0.9, 0, 0) draw rect, SDL2 with SDL_MapRGB, and final the rect color is not red rgb.</p>
  <pre><code>#include &lt;SDL.h&gt;
  #include &lt;cairo.h&gt;
  #include &lt;SDL_syswm.h&gt;
  #include &quot;windows.h&quot;
  
  COLORREF defaultTransparentColor = RGB(255, 0, 255);
  bool windowColorKey(SDL_Window *window, COLORREF colorKey) {
      SDL_SysWMinfo wmInfo;
      SDL_VERSION(&amp;wmInfo.version);  // Initialize wmInfo
      SDL_GetWindowWMInfo(window, &amp;wmInfo);
      HWND hWnd = wmInfo.info.win.window;
  
      // Change window type to layered
      SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
  
      // Set transparency color
      return SetLayeredWindowAttributes(hWnd, colorKey, 0, LWA_COLORKEY);
  }
  
  int main(int argc, char* argv[])
  {
      SDL_Init(SDL_INIT_VIDEO);
  
      SDL_Window *window;
      SDL_Renderer *renderer;
      SDL_CreateWindowAndRenderer(640, 480, SDL_WINDOW_SHOWN, &amp;window, &amp;renderer);
      windowColorKey(window, defaultTransparentColor);
      SDL_SetWindowTitle(window, &quot;Cairo test&quot;);
  
      cairo_surface_t *surface;
      cairo_t *cr;
  #if 1
      // 方式一 : 建立cairo, 建立texture, 在cairo上画图，然后update过去
      int windowWidth = 640, windowHeight = 480;
      surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, windowWidth, windowWidth);
      cr = cairo_create(surface);
      cairo_set_line_width(cr, 1);
  
      // cairo use red color
      cairo_set_source_rgb(cr, .9, 0, 0);
      cairo_rectangle(cr, 100, 100, 180, 90);
      cairo_stroke(cr);
      unsigned char *data;
      data = cairo_image_surface_get_data(surface);
  
      SDL_Texture *texture;
      SDL_Rect rect = {.x=0, .y=0, .w=windowWidth, .h=windowHeight};
  
      texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, windowWidth, windowHeight);
  //    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
      SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MUL);
      int widthPitch = windowWidth &lt;&lt; 2;
      SDL_UpdateTexture(texture, &amp;rect, data, widthPitch);
  #else
      // 方式二 : 建立texture, 从texture的像素数据建立cairo, 直接画到texture上去
      // 可能比方式一快, 我没读过cairo_image_surface_create_for_data的源码，不敢妄下定论
      SDL_Texture *texture;
      SDL_Rect rect = {.x=0, .y=0, .w=100, .h=100};
  
      texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 100, 100);
      SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
  
      void *pixel;
      int pitch = 400; // 一行的像素字节  ARGB32=4 byte, w = 100
      SDL_LockTexture(texture, &amp;rect, &amp;pixel, &amp;pitch);
      surface = cairo_image_surface_create_for_data(
              (unsigned char*) pixel,
              CAIRO_FORMAT_ARGB32, 100, 100, pitch
              );
      SDL_UnlockTexture(texture);
      cr = cairo_create(surface);
      cairo_set_line_width(cr, 10);
      cairo_set_source_rgb(cr, 255, 0, 0);
      cairo_arc(cr, 50, 50, 20, 0.0, 0.785);
      cairo_stroke(cr);
  #endif
  
      SDL_Event event;
      bool is_working = true;
      while (is_working) {
          while (SDL_PollEvent(&amp;event)) {
              switch (event.type) {
                  case SDL_QUIT:
                      SDL_DestroyWindow(window);
                      SDL_DestroyRenderer(renderer);
                      SDL_Quit();
                      is_working = false;
                      break;
              }
          }
  
          SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255);
          SDL_RenderClear(renderer);
          SDL_RenderCopy(renderer, texture, NULL, NULL);
          SDL_RenderPresent(renderer);
          SDL_Delay(66);
      }
  
      return 0;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/vcu0p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vcu0p.png" alt="enter image description here" /></a></p>
  <p>the rect is not red, what should i do ?</p>