#include <DxMGRView.h>
Public Member Functions | |
void | MakeSetTitle () |
virtual void | InitObject (void) |
virtual void | ExecRender (void) |
virtual BOOL | SetNewSurface (int ovsbpos=0) |
virtual void | OnInitialUpdate () |
Public Attributes | |
RECT | renderRect |
Protected Member Functions | |
CDxMGRView () | |
virtual | ~CDxMGRView () |
virtual void | AssertValid () const |
virtual void | Dump (CDumpContext &dc) const |
Definition at line 23 of file DxMGRView.h.
CDxMGRView | ( | ) | [protected] |
Definition at line 28 of file DxMGRView.cpp.
References VIEW_8_MAX.
00029 { 00030 cnstXYRate = true; 00031 00032 renderRect.left = 0; 00033 renderRect.top = 0; 00034 renderRect.right = 0; 00035 renderRect.bottom = 0; 00036 00037 cMax = VIEW_8_MAX; 00038 cMin = 0; 00039 00040 vSBntch = 1; // スクロールピッチ 00041 }
~CDxMGRView | ( | ) | [protected, virtual] |
Definition at line 45 of file DxMGRView.cpp.
void AssertValid | ( | ) | const [protected, virtual] |
Reimplemented from CExView.
Definition at line 75 of file DxMGRView.cpp.
00076 { 00077 CDxBaseView::AssertValid(); 00078 }
void Dump | ( | CDumpContext & | dc | ) | const [protected, virtual] |
Reimplemented from CExView.
Definition at line 81 of file DxMGRView.cpp.
00082 { 00083 CDxBaseView::Dump(dc); 00084 }
void ExecRender | ( | void | ) | [virtual] |
Reimplemented from CDxBaseView.
Definition at line 582 of file DxMGRView.cpp.
References CDxBaseView::d3dParam, IDS_STR_FAIL_CLR_WND, IDS_STR_FAIL_RESTR_DX9DEV, IDS_STR_FAIL_TRNS_BAKBUF, CDxBaseView::lpBackBuffer, CDxBaseView::lpD3DDevice, CDxBaseView::lpSurface, CDxMGRView::MakeSetTitle(), CExView::pFrame, and jbxwl::ResetDx9Device().
00583 { 00584 HRESULT hr; 00585 00586 MakeSetTitle(); 00587 00588 hr = lpD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0); 00589 if (FAILED(hr)) { 00590 CString mesg; 00591 mesg.LoadString(IDS_STR_FAIL_CLR_WND); 00592 MessageBox(_T("CDxMGRView::ExecRender():\n\n") + mesg); 00593 return; 00594 } 00595 00596 hr = lpD3DDevice->StretchRect(lpSurface, NULL, lpBackBuffer, NULL, D3DTEXF_NONE); 00597 if (FAILED(hr)) { 00598 CString mesg; 00599 mesg.LoadString(IDS_STR_FAIL_TRNS_BAKBUF); 00600 MessageBox(_T("CDxMGRView::ExecRender():\n\n") + mesg); 00601 return; 00602 } 00603 00604 hr = lpD3DDevice->Present(NULL, NULL, NULL, NULL); 00605 if (FAILED(hr)) { 00606 hr = ResetDx9Device(lpD3DDevice, &d3dParam, this); 00607 if (FAILED(hr)) { 00608 CString mesg; 00609 mesg.LoadString(IDS_STR_FAIL_RESTR_DX9DEV); 00610 MessageBox(_T("CDxMGRView::ExecRender():\n\n") + mesg); 00611 pFrame->SendMessage(WM_CLOSE); 00612 //GetParentFrame()->DestroyWindow(); 00613 } 00614 else ExecRender(); 00615 } 00616 }
void InitObject | ( | void | ) | [virtual] |
Reimplemented from CDxBaseView.
Definition at line 620 of file DxMGRView.cpp.
References CDxBaseView::bufferSize, CExView::colorMode, jbxwl::Dx9GetBackBuffer(), CExView::hasViewData, IDS_STR_FAIL_REGET_BAKBUF, IDS_STR_FAIL_REGET_SURFACE, IDS_STR_FAIL_RETRNS_SURFACE, CDxBaseView::lpBackBuffer, CDxBaseView::lpD3DDevice, CDxBaseView::lpSurface, CDxMGRView::SetNewSurface(), CExView::viewData, and CExView::vSBpos.
00621 { 00622 bufferSize = Dx9GetBackBuffer(lpD3DDevice, &lpBackBuffer); 00623 if (bufferSize.x<0) { 00624 CString mesg; 00625 mesg.LoadString(IDS_STR_FAIL_REGET_BAKBUF); 00626 MessageBox(_T("CDxMGRView::InitObject():\n\n") + mesg); 00627 return; 00628 } 00629 00630 HRESULT hr; 00631 if (colorMode==GRAPH_COLOR_RGB || colorMode==GRAPH_COLOR_BGR) { 00632 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL); 00633 } 00634 else if (colorMode==GRAPH_COLOR_ARGB || colorMode==GRAPH_COLOR_RGBA) { 00635 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL); 00636 } 00637 else if (colorMode==GRAPH_COLOR_XRGB) { 00638 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL); 00639 } 00640 else if (colorMode==GRAPH_COLOR_ABGR || colorMode==GRAPH_COLOR_BGRA) { 00641 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL); 00642 } 00643 else if (colorMode==GRAPH_COLOR_XBGR) { 00644 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL); 00645 } 00646 else if (colorMode==GRAPH_COLOR_ARGB16 || colorMode==GRAPH_COLOR_RGBA16) { 00647 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &lpSurface, NULL); 00648 } 00649 else { // GRAPH_COLOR_MONO, MONO16, RGB16 00650 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &lpSurface, NULL); 00651 } 00652 00653 if (FAILED(hr)) { 00654 CString mesg; 00655 mesg.LoadString(IDS_STR_FAIL_REGET_SURFACE); 00656 MessageBox(_T("CDxMGRView::InitObject():\n\n") + mesg); 00657 return; 00658 } 00659 00660 hasViewData = SetNewSurface(vSBpos); 00661 if (!hasViewData) { 00662 CString mesg; 00663 mesg.LoadString(IDS_STR_FAIL_RETRNS_SURFACE); 00664 MessageBox(_T("CDxMGRView::InitObject():\n\n") + mesg); 00665 return; 00666 } 00667 return; 00668 }
void MakeSetTitle | ( | ) |
Definition at line 672 of file DxMGRView.cpp.
References CExView::clientRate, CExDocument::endNo, IDS_STR_IMG_NUM, jbxwl::numbering_name_t(), CExView::pDoc, CExDocument::preTitle, CExDocument::pstTitle, CExView::SetTitle(), CExDocument::startNo, CExDocument::Title, CExView::Title, CExView::vSBmax, and CExView::vSBpos.
Referenced by CDxMGRView::ExecRender(), and CDxMGRView::SetNewSurface().
00673 { 00674 Title = pDoc->preTitle + pDoc->Title + pDoc->pstTitle; 00675 if (vSBmax>=1) { 00676 CString mesg; 00677 mesg.LoadString(IDS_STR_IMG_NUM); 00678 mesg = _T(" ") + mesg + _T(" %d"); 00679 int no = pDoc->startNo + vSBpos*Sign(pDoc->endNo - pDoc->startNo); 00680 00681 Title += numbering_name_t((LPCTSTR)mesg, no); 00682 } 00683 00684 if (clientRate!=1.0) { 00685 CString szprcnt; 00686 szprcnt.Format(_T(" (%d%%)"), (int)(clientRate*100+0.5)); 00687 Title = Title + szprcnt; 00688 } 00689 this->SetTitle(Title); 00690 }
void OnInitialUpdate | ( | void | ) | [virtual] |
Reimplemented from CDxBaseView.
Definition at line 98 of file DxMGRView.cpp.
References CDxBaseView::bufferSize, CExDocument::cMax, CExView::cMax, CExDocument::cMin, CExView::cMin, CExDocument::cmnHead, CExView::cmnHead, CExDocument::colorMode, CExView::colorMode, CExFrame::doneErrorMessage, jbxwl::Dx9GetBackBuffer(), CExView::hasViewData, IDS_STR_FAIL_CRT_BAKBUF, IDS_STR_FAIL_CRT_SURFACE, IDS_STR_FAIL_GET_DX9DEV, IDS_STR_FAIL_TRNS_SURFACE, IDS_STR_INVLD_VWMODE, IDS_STR_UNKWN_VWMODE, IDS_STR_UNSPT_VWMODE, CDxBaseView::InitDevice(), CDxBaseView::lpBackBuffer, CDxBaseView::lpD3DDevice, CDxBaseView::lpSurface, CExView::origXSize, CExView::origYSize, CExView::pDoc, CExView::pFrame, CDxMGRView::renderRect, CDxMGRView::SetNewSurface(), CExView::SetWindowSize(), CExView::sizeXYRate, CExView::usePlane, VIEW_8_MAX, VIEW_8_MIN, VIEW_XDIR, VIEW_YDIR, VIEW_ZDIR, CExView::viewData, CExView::viewMode, CExDocument::vMax, CExView::vMax, CExDocument::vMin, CExView::vMin, CExView::vSBmax, CExView::vSBpos, CExView::xsize, CExView::ysize, and CExView::zsize.
00099 { 00100 cmnHead = pDoc->cmnHead; 00101 if (isNull(cmnHead.grptr)) return; 00102 00103 colorMode = pDoc->colorMode & GRAPH_COLOR_MASK; 00104 if (pDoc->colorMode & GRAPH_COLOR_USE_PLANE) usePlane = true; 00105 00106 if (usePlane) { 00107 if (colorMode==GRAPH_COLOR_RGB && cmnHead.zsize!=3) colorMode = GRAPH_COLOR_MONO; 00108 else if (colorMode==GRAPH_COLOR_BGR && cmnHead.zsize!=3) colorMode = GRAPH_COLOR_MONO; 00109 else if (colorMode==GRAPH_COLOR_ARGB && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO; 00110 else if (colorMode==GRAPH_COLOR_ABGR && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO; 00111 else if (colorMode==GRAPH_COLOR_RGBA && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO; 00112 else if (colorMode==GRAPH_COLOR_BGRA && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO; 00113 else if (colorMode==GRAPH_COLOR_XRGB && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO; 00114 else if (colorMode==GRAPH_COLOR_XBGR && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO; 00115 } 00116 if (colorMode==GRAPH_COLOR_MONO) usePlane = false; 00117 00118 // 00119 xsize = cmnHead.xsize; 00120 ysize = cmnHead.ysize; 00121 00122 // 表示モード 00123 if (colorMode==GRAPH_COLOR_RGB || colorMode==GRAPH_COLOR_BGR || 00124 colorMode==GRAPH_COLOR_XRGB || colorMode==GRAPH_COLOR_ARGB || colorMode==GRAPH_COLOR_RGBA || 00125 colorMode==GRAPH_COLOR_XBGR || colorMode==GRAPH_COLOR_ABGR || colorMode==GRAPH_COLOR_BGRA) { 00126 if (viewMode==VIEW_ZDIR) { // Z 00127 xsize = cmnHead.xsize; 00128 ysize = cmnHead.ysize; 00129 zsize = 1; 00130 } 00131 else { 00132 CString mesg; 00133 mesg.LoadString(IDS_STR_UNSPT_VWMODE); 00134 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00135 pFrame->doneErrorMessage = TRUE; 00136 return; 00137 } 00138 } 00139 00140 else { 00141 if (viewMode==VIEW_ZDIR) { // Z 00142 xsize = cmnHead.xsize; 00143 ysize = cmnHead.ysize; 00144 zsize = cmnHead.zsize; 00145 } 00146 else if (viewMode==VIEW_XDIR) { // X 00147 xsize = cmnHead.ysize; 00148 ysize = cmnHead.zsize; 00149 zsize = cmnHead.xsize; 00150 if (ysize<=1) { 00151 CString mesg; 00152 mesg.LoadString(IDS_STR_INVLD_VWMODE); 00153 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00154 pFrame->doneErrorMessage = TRUE; 00155 return; 00156 } 00157 } 00158 else if (viewMode==VIEW_YDIR) { // Y 00159 xsize = cmnHead.xsize; 00160 ysize = cmnHead.zsize; 00161 zsize = cmnHead.ysize; 00162 if (ysize<=1) { 00163 CString mesg; 00164 mesg.LoadString(IDS_STR_INVLD_VWMODE); 00165 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00166 pFrame->doneErrorMessage = TRUE; 00167 return; 00168 } 00169 00170 } 00171 else { 00172 CString mesg; 00173 mesg.LoadString(IDS_STR_UNKWN_VWMODE); 00174 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00175 pFrame->doneErrorMessage = TRUE; 00176 return; 00177 } 00178 } 00179 00180 // 00181 cMax = pDoc->cMax; 00182 cMin = pDoc->cMin; 00183 vMax = pDoc->vMax; 00184 vMin = pDoc->vMin; 00185 00186 // 00187 D3DFORMAT format; 00188 00189 // RGB 8bit/plane 00190 // なんで xsize, ysize は偶数なんだっけ!? 00191 if (colorMode==GRAPH_COLOR_RGB || colorMode==GRAPH_COLOR_BGR) { 00192 //xsize = (((xsize*3+3)/4)*4+2)/3; 00193 //ysize = (((ysize*3+3)/4)*4+2)/3; 00194 viewData.set(xsize, ysize, 1, 24); 00195 format = D3DFMT_X8R8G8B8; 00196 vMax = cMax = VIEW_8_MAX; 00197 vMin = cMin = VIEW_8_MIN; 00198 } 00199 // ARGB/RGBA 8bit/plane 00200 else if (colorMode==GRAPH_COLOR_ARGB || colorMode==GRAPH_COLOR_RGBA) { 00201 viewData.set(xsize, ysize, 1, 32); 00202 format = D3DFMT_A8R8G8B8; 00203 vMax = cMax = VIEW_8_MAX; 00204 vMin = cMin = VIEW_8_MIN; 00205 } 00206 // XRGB 8bit/plane 00207 else if (colorMode==GRAPH_COLOR_XRGB) { 00208 viewData.set(xsize, ysize, 1, 32); 00209 format = D3DFMT_X8R8G8B8; 00210 vMax = cMax = VIEW_8_MAX; 00211 vMin = cMin = VIEW_8_MIN; 00212 } 00213 // ABGR/BGRA 8bit/plane 00214 else if (colorMode==GRAPH_COLOR_ABGR || colorMode==GRAPH_COLOR_BGRA) { 00215 viewData.set(xsize, ysize, 1, 32); 00216 format = D3DFMT_A8R8G8B8; 00217 vMax = cMax = VIEW_8_MAX; 00218 vMin = cMin = VIEW_8_MIN; 00219 } 00220 // XBGR 8bit/plane 00221 else if (colorMode==GRAPH_COLOR_XBGR) { 00222 viewData.set(xsize, ysize, 1, 32); 00223 format = D3DFMT_X8R8G8B8; 00224 vMax = cMax = VIEW_8_MAX; 00225 vMin = cMin = VIEW_8_MIN; 00226 } 00227 // ARGB16/RGBA16 16bit/plane 00228 else if (colorMode==GRAPH_COLOR_ARGB16 || colorMode==GRAPH_COLOR_RGBA16) { 00229 //xsize += xsize%2; 00230 //ysize += ysize%2; 00231 viewData.set(xsize, ysize, 1, 16); 00232 format = D3DFMT_A4R4G4B4; 00233 vMax = cMax = SWORDMAX; 00234 vMin = cMin = SWORDMIN; 00235 } 00236 // RGB16 16bit/plane 00237 else if (colorMode==GRAPH_COLOR_RGB16) { 00238 //xsize += xsize%2; 00239 //ysize += ysize%2; 00240 viewData.set(xsize, ysize, 1, 16); 00241 format = D3DFMT_R5G6B5; 00242 vMax = cMax = SWORDMAX; 00243 vMin = cMin = SWORDMIN; 00244 } 00245 // GRAPH_COLOR_MONO, MONO16 8,16bit/plane (MONO16は MONOに変換されて表示される) 00246 else { 00247 //xsize = ((xsize+3)/4)*4; 00248 //ysize = ((ysize+3)/4)*4; 00249 viewData.set(xsize, ysize); 00250 format = D3DFMT_R5G6B5; 00251 } 00252 00253 // 00254 origXSize = xsize; 00255 origYSize = ysize; 00256 sizeXYRate = (double)ysize/(double)xsize; 00257 00258 renderRect.top = 0; 00259 renderRect.left = 0; 00260 renderRect.right = xsize; 00261 renderRect.bottom = ysize; 00262 vSBmax = zsize - 1; 00263 00264 SetScrollRange(SB_VERT, 0, vSBmax); 00265 SetScrollPos(SB_VERT, vSBpos); 00266 00267 // 00268 // DX9 00269 // 00270 BOOL rslt = InitDevice(xsize, ysize); 00271 if (!rslt) { 00272 CString mesg; 00273 mesg.LoadString(IDS_STR_FAIL_GET_DX9DEV); 00274 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00275 pFrame->doneErrorMessage = TRUE; 00276 return; 00277 } 00278 00279 bufferSize = Dx9GetBackBuffer(lpD3DDevice, &lpBackBuffer); 00280 if (bufferSize.x<0) { 00281 CString mesg; 00282 mesg.LoadString(IDS_STR_FAIL_CRT_BAKBUF); 00283 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00284 return; 00285 } 00286 00287 HRESULT hr = lpD3DDevice->CreateOffscreenPlainSurface(xsize, ysize, format, D3DPOOL_DEFAULT, &lpSurface, NULL); 00288 if (FAILED(hr)) { 00289 CString mesg; 00290 mesg.LoadString(IDS_STR_FAIL_CRT_SURFACE); 00291 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00292 pFrame->doneErrorMessage = TRUE; 00293 return; 00294 } 00295 00296 hasViewData = SetNewSurface(vSBpos); 00297 if (!hasViewData) { 00298 CString mesg; 00299 mesg.LoadString(IDS_STR_FAIL_TRNS_SURFACE); 00300 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg); 00301 pFrame->doneErrorMessage = TRUE; 00302 return; 00303 } 00304 00305 00306 // 00307 SetWindowSize(viewData.xsize, viewData.ysize); 00308 return; 00309 }
BOOL SetNewSurface | ( | int | ovsbpos = 0 |
) | [virtual] |
Reimplemented from CExView.
Definition at line 313 of file DxMGRView.cpp.
References CExView::cMax, CExView::cMin, CExView::cmnHead, CExView::colorMode, IDS_STR_DLTD_DATA, IDS_STR_ERROR, CDxBaseView::lpSurface, CDxMGRView::MakeSetTitle(), CExView::prevSBpos, CDxMGRView::renderRect, VIEW_8_MAX, VIEW_8_MIN, VIEW_XDIR, VIEW_YDIR, VIEW_ZDIR, CExView::viewData, CExView::viewMode, CExView::vMax, CExView::vMin, and CExView::vSBpos.
Referenced by CDxMGRView::InitObject(), and CDxMGRView::OnInitialUpdate().
00314 { 00315 int point, n; 00316 double ca, cb; 00317 HRESULT hr; 00318 00319 if (isNull(viewData.grptr)) { 00320 CString mesg, noti; 00321 mesg.LoadString(IDS_STR_DLTD_DATA); 00322 noti.LoadString(IDS_STR_ERROR); 00323 MessageBox(_T("CDxMGRView::SetNewSurface():\n\n") + mesg, noti, MB_OK); 00324 return FALSE; 00325 } 00326 00327 // 00328 check_endian(); 00329 MakeSetTitle(); 00330 00331 // コントラスト調整 00332 // cMax, cMin: 可変 vMax, vMin:コントラストの上限と下限(固定) 00333 if (cMax==cMin) cMax = cMin + 1; 00334 ca = ((double)(vMax-vMin))/((double)(cMax-cMin)); 00335 cb = ((double)(vMin-cMin))/((double)(cMax-cMin)); 00336 00337 // RGB 8bit/plane 00338 if (colorMode==GRAPH_COLOR_RGB) { 00339 for (int k=0; k<3; k++) { 00340 if (HostEndian==BIG_ENDIAN) n = k; 00341 else n = 2 - k; 00342 for (int j=0; j<cmnHead.ysize; j++) { 00343 for (int i=0; i<cmnHead.xsize; i++) { 00344 uByte* ptr = &viewData.point(i, j); 00345 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5); 00346 point = Min(point, VIEW_8_MAX); 00347 point = Max(point, VIEW_8_MIN); 00348 ptr[n] = point; 00349 } 00350 } 00351 } 00352 00353 int srcpitch = viewData.xsize*3; 00354 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00355 } 00356 00357 // BGR 8bit/plane 00358 else if (colorMode==GRAPH_COLOR_BGR) { 00359 for (int k=0; k<3; k++) { 00360 if (HostEndian==BIG_ENDIAN) n = 2 - k; 00361 else n = k; 00362 for (int j=0; j<cmnHead.ysize; j++) { 00363 for (int i=0; i<cmnHead.xsize; i++) { 00364 uByte* ptr = &viewData.point(i, j); 00365 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5); 00366 point = Min(point, VIEW_8_MAX); 00367 point = Max(point, VIEW_8_MIN); 00368 ptr[n] = point; 00369 } 00370 } 00371 } 00372 00373 int srcpitch = viewData.xsize*3; 00374 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00375 } 00376 00377 // XRGB/ARGB 8bit/plane 00378 else if (colorMode==GRAPH_COLOR_XRGB || colorMode==GRAPH_COLOR_ARGB) { 00379 for (int k=0; k<4; k++) { 00380 if (HostEndian==BIG_ENDIAN) n = k; 00381 else n = 3 - k; 00382 for (int j=0; j<cmnHead.ysize; j++) { 00383 for (int i=0; i<cmnHead.xsize; i++) { 00384 uByte* ptr = &viewData.point(i, j); 00385 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5); 00386 point = Min(point, VIEW_8_MAX); 00387 point = Max(point, VIEW_8_MIN); 00388 ptr[n] = point; 00389 } 00390 } 00391 } 00392 00393 int srcpitch = viewData.xsize*4; 00394 if (colorMode==GRAPH_COLOR_XRGB) { 00395 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_X8R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00396 } 00397 else { 00398 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00399 } 00400 } 00401 00402 // RGBA 8bit/plane 00403 else if (colorMode==GRAPH_COLOR_RGBA) { 00404 for (int k=0; k<4; k++) { 00405 if (HostEndian==BIG_ENDIAN) n = 3 - k; 00406 else n = k; 00407 for (int j=0; j<cmnHead.ysize; j++) { 00408 for (int i=0; i<cmnHead.xsize; i++) { 00409 uByte* ptr = &viewData.point(i, j); 00410 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5); 00411 point = Min(point, VIEW_8_MAX); 00412 point = Max(point, VIEW_8_MIN); 00413 ptr[n] = point; 00414 } 00415 } 00416 } 00417 00418 int srcpitch = viewData.xsize*4; 00419 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8B8G8R8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00420 } 00421 00422 // XBGR/ABGR 8bit/plane 00423 else if (colorMode==GRAPH_COLOR_XBGR || colorMode==GRAPH_COLOR_ABGR) { 00424 for (int k=0; k<4; k++) { 00425 if (HostEndian==BIG_ENDIAN) n = k; 00426 else n = 3 - k; 00427 for (int j=0; j<cmnHead.ysize; j++) { 00428 for (int i=0; i<cmnHead.xsize; i++) { 00429 uByte* ptr = &viewData.point(i, j); 00430 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5); 00431 point = Min(point, VIEW_8_MAX); 00432 point = Max(point, VIEW_8_MIN); 00433 ptr[n] = point; 00434 } 00435 } 00436 } 00437 00438 int srcpitch = viewData.xsize*4; 00439 if (colorMode==GRAPH_COLOR_XBGR) { 00440 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_X8B8G8R8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00441 } 00442 else { 00443 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8B8G8R8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00444 } 00445 } 00446 00447 // BGRA 8bit/plane 00448 else if (colorMode==GRAPH_COLOR_BGRA) { 00449 for (int k=0; k<4; k++) { 00450 if (HostEndian==BIG_ENDIAN) n = 3 - k; 00451 else n = k; 00452 for (int j=0; j<cmnHead.ysize; j++) { 00453 for (int i=0; i<cmnHead.xsize; i++) { 00454 uByte* ptr = &viewData.point(i, j); 00455 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5); 00456 point = Min(point, VIEW_8_MAX); 00457 point = Max(point, VIEW_8_MIN); 00458 ptr[n] = point; 00459 } 00460 } 00461 } 00462 00463 int srcpitch = viewData.xsize*4; 00464 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00465 } 00466 00467 // RGB16/ARGB16/RGBA16 16bit/plane 00468 else if (colorMode==GRAPH_COLOR_RGB16 || colorMode==GRAPH_COLOR_ARGB16 || colorMode==GRAPH_COLOR_RGBA16) { 00469 uWord* src = NULL; 00470 uWord* dst = NULL; 00471 00472 if (prevSBpos!=vSBpos) { 00473 if (viewMode==VIEW_ZDIR) { 00474 for (int j=0; j<cmnHead.ysize; j++) { 00475 for (int i=0; i<cmnHead.xsize; i++) { 00476 src = (uWord*)&cmnHead.point(i, j, vSBpos); 00477 dst = (uWord*)&viewData.point(i, j); 00478 point = (int)(*src*ca + vMax*cb + 0.5); 00479 //point = Min(point, vMax); 00480 //point = Max(point, vMin); 00481 *dst = point; 00482 } 00483 } 00484 } 00485 else if (viewMode==VIEW_XDIR) { 00486 for (int j=0; j<cmnHead.zsize; j++) { 00487 for (int i=0; i<cmnHead.ysize; i++) { 00488 src = (uWord*)&cmnHead.point(vSBpos, i, j); 00489 dst = (uWord*)&viewData.point(i, j); 00490 point = (int)(*src*ca + vMax*cb + 0.5); 00491 //point = Min(point, vMax); 00492 //point = Max(point, vMin); 00493 *dst = point; 00494 } 00495 } 00496 } 00497 else if (viewMode==VIEW_YDIR) { 00498 for (int j=0; j<cmnHead.zsize; j++) { 00499 for (int i=0; i<cmnHead.xsize; i++) { 00500 src = (uWord*)&cmnHead.point(i, cmnHead.ysize-1-vSBpos, j); 00501 dst = (uWord*)&viewData.point(i, j); 00502 point = (int)(*src*ca + vMax*cb + 0.5); 00503 //point = Min(point, vMax); 00504 //point = Max(point, vMin); 00505 *dst = point; 00506 } 00507 } 00508 } 00509 else return FALSE; 00510 } 00511 00512 ntoh_data(viewData.grptr, viewData.lsize, 2); 00513 int srcpitch = viewData.xsize*2; 00514 if (colorMode==GRAPH_COLOR_RGB16) { 00515 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_R5G6B5, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00516 } 00517 else if (colorMode==GRAPH_COLOR_ARGB16) { 00518 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A4R4G4B4, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00519 } 00520 else { // GRAPH_COLOR_RGBA16 00521 // R4G4B4A4 -> A4R4G4B4 00522 for (int i=0; i<viewData.xsize*viewData.ysize*2; i+=2) { 00523 int r = (viewData.grptr[i] &0xf0)>>4; 00524 int g = (viewData.grptr[i] &0x0f)<<4; 00525 int b = (viewData.grptr[i+1]&0xf0)>>4; 00526 int a = (viewData.grptr[i+1]&0x0f)<<4; 00527 viewData.grptr[i] = (uByte)(a + r); 00528 viewData.grptr[i+1] = (uByte)(g + b); 00529 } 00530 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A4R4G4B4, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00531 } 00532 } 00533 00534 // Monochrome 8,16bit/plane cmnHead は8bitに変換済み 00535 else if (colorMode==GRAPH_COLOR_MONO || colorMode==GRAPH_COLOR_MONO16) { 00536 if (prevSBpos!=vSBpos) { 00537 if (viewMode==VIEW_ZDIR) { 00538 for (int j=0; j<cmnHead.ysize; j++) { 00539 for (int i=0; i<cmnHead.xsize; i++) { 00540 point = (int)(cmnHead.point(i, j, vSBpos)*ca + VIEW_8_MAX*cb + 0.5); 00541 point = Min(point, VIEW_8_MAX); 00542 point = Max(point, 0); 00543 viewData.point(i, j) = point; 00544 } 00545 } 00546 } 00547 else if (viewMode==VIEW_XDIR) { 00548 for (int j=0; j<cmnHead.zsize; j++) { 00549 for (int i=0; i<cmnHead.ysize; i++) { 00550 point = (int)(cmnHead.point(vSBpos, i, j)*ca + VIEW_8_MAX*cb + 0.5); 00551 point = Min(point, VIEW_8_MAX); 00552 point = Max(point, 0); 00553 viewData.point(i, j) = point; 00554 } 00555 } 00556 } 00557 else if (viewMode==VIEW_YDIR) { 00558 for (int j=0; j<cmnHead.zsize; j++) { 00559 for (int i=0; i<cmnHead.xsize; i++) { 00560 point = (int)(cmnHead.point(i, cmnHead.ysize-1-vSBpos, j)*ca + VIEW_8_MAX*cb + 0.5); 00561 point = Min(point, VIEW_8_MAX); 00562 point = Max(point, 0); 00563 viewData.point(i, j) = point; 00564 } 00565 } 00566 } 00567 else return FALSE; 00568 } 00569 00570 // GRAPH_COLOR_MONO16 は 8bitに変換されている 00571 int srcpitch = viewData.xsize; 00572 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_L8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0); 00573 } 00574 00575 if (FAILED(hr)) return FALSE; 00576 00577 return TRUE; 00578 }
RECT renderRect |
Definition at line 31 of file DxMGRView.h.
Referenced by CDxMGRView::OnInitialUpdate(), and CDxMGRView::SetNewSurface().