if (NS_NewImageManager(&gImageManager) != NS_OK||gImageManager->Init() != NS_OK) { ::MessageBox(NULL, "Can't initialize the image library",class1Name, MB_OK); } gImageManager->SetCacheSize(1024*1024);
{ nsresult result; gImageManager = do_GetService(kImageManagerCID, &result); if ((NS_FAILED(result)) || gImageManager->Init() != NS_OK) { ::MessageBox(NULL, "Can't initialize the image library",class1Name, MB_OK); } else gImageManager->SetCacheSize(1024*1024); }
WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam){HMENU     hMenu;char      szFile[256];float     blendamount;nsString  str;PRInt32   numerror;PRUint32  size;  switch (msg)     {    case WM_COMMAND:      hMenu = GetMenu(hWnd);      switch (LOWORD(param))         {        case TIMER_OPEN:           if (OpenFileDialog(szFile, 256))            MyLoadImage(szFile,PR_FALSE,NULL);        case OPENBLD:          if (OpenFileDialog(szFile, 256))            {            if (gBlendImage!=nsnull)               {              NS_RELEASE(gBlendImage);              gBlendImage = nsnull;              }            MyLoadImage(szFile,PR_TRUE,&gBlendImage);            }          break;                  case TIMER_EXIT:          ::DestroyWindow(hWnd);          exit(0);          break;        case RDMSK:           // read mask            if (gMaskImage!=nsnull)               {              NS_RELEASE(gMaskImage);              gMaskImage = nsnull;              }            if (OpenFileDialog(szFile, 256))              MyLoadImage(szFile,PR_TRUE,&gMaskImage);          break;        case COMPRESET:            Restore(gImageblender,gImage);          break;        case COMPINT:         // compostite interactive          InterActiveBlend(gImageblender,gImage);          break;        case COMPTST:         // composite basic test          IsImageLoaded();          gBlendMessage->GetText(str,3,size);          blendamount = (float)(str.ToInteger(&numerror))/100.0f;          if(blendamount < 0.0)            blendamount = 0.0f;          if(blendamount > 1.0)            blendamount = 1.0f;          Compositetest(gImageblender,gImage,0,0,0,0,0,0,blendamount,PR_TRUE);          break;        case COMPTSTSPEED:    // composit speed test          SpeedTestBlend(gImageblender,gImage);          break;        case BSTNOOPT:        case BSTOPT:          IsImageLoaded();          if(gImage)            {            PRBool opt;            nsIRenderingContext *drawCtx = gWindow->GetRenderingContext();            if(LOWORD(param) == BSTNOOPT)              opt = PR_FALSE;            else              opt = PR_TRUE;            speedtest(gImage,drawCtx, 0, 0, gImage->GetWidth(), gImage->GetHeight(),opt);            }          break;        case DRAWTEST:            if(gWindow)              {              nsIRenderingContext *drawCtx = gWindow->GetRenderingContext();              drawtest(drawCtx);              }          break;        case FILLTEST:            if(gWindow)              {              nsIRenderingContext *drawCtx = gWindow->GetRenderingContext();              filltest(drawCtx);              }          break;        case ARCTEST:            if(gWindow)              {              nsIRenderingContext *drawCtx = gWindow->GetRenderingContext();              arctest(drawCtx);              }          break;        default:            break;      }      break;    case WM_CREATE:      // Initialize image library      if (NS_NewImageManager(&gImageManager) != NS_OK||gImageManager->Init() != NS_OK)         {        ::MessageBox(NULL, "Can't initialize the image library",class1Name, MB_OK);        }	        gImageManager->SetCacheSize(1024*1024);      break;    case WM_DESTROY:      MyInterrupt();      MyReleaseImages();      CleanUpBlend();            if (gImageGroup != nsnull)         {        NS_RELEASE(gImageGroup);        }      if (gImageManager != nsnull)         {        NS_RELEASE(gImageManager);        }      if (gBlendImage)         {        NS_RELEASE(gBlendImage);        gBlendImage = NULL;        }      PostQuitMessage(0);      break;    default:      break;    }  return DefWindowProc(hWnd, msg, param, lparam);}