modules/graphics/src/main/native-glass/win/Pixels.cpp

Print this page




  90     bmi.biHeight = -height;
  91     bmi.biPlanes = 1;
  92     bmi.biBitCount = 32;
  93     bmi.biCompression = BI_RGB;
  94     bmi.biSizeImage = imageSize;
  95 
  96     HBITMAP hBitmap = ::CreateDIBSection(NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS, &bitmapBits, NULL, 0);
  97 
  98     if (bitmapBits) {
  99         memcpy(bitmapBits, bits, imageSize);
 100         Attach(hBitmap);
 101     }
 102     ASSERT((HBITMAP)*this);
 103 }
 104 
 105 HICON Pixels::CreateIcon(JNIEnv *env, jobject jPixels, BOOL fIcon, jint x, jint y)
 106 {
 107     Pixels pixels(env, jPixels);
 108 
 109     Bitmap mask(pixels.GetWidth(), pixels.GetHeight());
 110     Bitmap bitmap(pixels);
 111 
 112     ICONINFO iconInfo;
 113     memset(&iconInfo, 0, sizeof(ICONINFO));
 114     iconInfo.hbmMask = mask;
 115     iconInfo.hbmColor = bitmap;
 116     iconInfo.fIcon = fIcon;
 117     iconInfo.xHotspot = x;
 118     iconInfo.yHotspot = y;
 119     HICON hIcon = ::CreateIconIndirect(&iconInfo);
 120     ASSERT(hIcon);
 121 
 122     ::GdiFlush();
 123 
 124     return hIcon;
 125 }
 126 
 127 Pixels::Pixels(JNIEnv *env, jobject jPixels)
 128 {
 129     env->CallVoidMethod(jPixels, javaIDs.Pixels.attachData, ptr_to_jlong(this));
 130     CheckAndClearException(env);




  90     bmi.biHeight = -height;
  91     bmi.biPlanes = 1;
  92     bmi.biBitCount = 32;
  93     bmi.biCompression = BI_RGB;
  94     bmi.biSizeImage = imageSize;
  95 
  96     HBITMAP hBitmap = ::CreateDIBSection(NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS, &bitmapBits, NULL, 0);
  97 
  98     if (bitmapBits) {
  99         memcpy(bitmapBits, bits, imageSize);
 100         Attach(hBitmap);
 101     }
 102     ASSERT((HBITMAP)*this);
 103 }
 104 
 105 HICON Pixels::CreateIcon(JNIEnv *env, jobject jPixels, BOOL fIcon, jint x, jint y)
 106 {
 107     Pixels pixels(env, jPixels);
 108 
 109     Bitmap mask(pixels.GetWidth(), pixels.GetHeight());
 110     DIBitmap bitmap(pixels);
 111 
 112     ICONINFO iconInfo;
 113     memset(&iconInfo, 0, sizeof(ICONINFO));
 114     iconInfo.hbmMask = mask;
 115     iconInfo.hbmColor = bitmap;
 116     iconInfo.fIcon = fIcon;
 117     iconInfo.xHotspot = x;
 118     iconInfo.yHotspot = y;
 119     HICON hIcon = ::CreateIconIndirect(&iconInfo);
 120     ASSERT(hIcon);
 121 
 122     ::GdiFlush();
 123 
 124     return hIcon;
 125 }
 126 
 127 Pixels::Pixels(JNIEnv *env, jobject jPixels)
 128 {
 129     env->CallVoidMethod(jPixels, javaIDs.Pixels.attachData, ptr_to_jlong(this));
 130     CheckAndClearException(env);