Click here to Skip to main content
15,909,242 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAsynch Serial Comms - IO Completion Pin
louis15-Sep-04 22:40
louis15-Sep-04 22:40 
GeneralVisual C++ (MFC) : Using Matrix to set an part of an image to zero Pin
pohcb_sonic15-Sep-04 21:50
pohcb_sonic15-Sep-04 21:50 
GeneralRe: Visual C++ (MFC) : Using Matrix to set an part of an image to zero Pin
V.15-Sep-04 22:15
professionalV.15-Sep-04 22:15 
GeneralRe: Visual C++ (MFC) : Using Matrix to set an part of an image to zero Pin
pohcb_sonic16-Sep-04 15:21
pohcb_sonic16-Sep-04 15:21 
GeneralRe: Visual C++ (MFC) : Using Matrix to set an part of an image to zero Pin
V.16-Sep-04 20:39
professionalV.16-Sep-04 20:39 
GeneralUnable to view document Pin
Mughi15-Sep-04 21:43
Mughi15-Sep-04 21:43 
QuestionCan anyone help me create this DLL? Pin
noeppkes15-Sep-04 21:34
noeppkes15-Sep-04 21:34 
GeneralVisual C++ (MFC) : Using Matrix to set an part of an image to zero Pin
pohcb_sonic15-Sep-04 20:17
pohcb_sonic15-Sep-04 20:17 
Hi! I'm new to MFC in Visual C++ programming. I had previously used it to do console applications but never used MFC before. I had a problem; I was told to set a 4 by 4 area by using Matrix in MFC coding and use it to check whether the image has any little "black spots". If it does, I have to set these small little "black spots" of the image from "255" or anything else to zero.

So How do I do it?

Pls do kindly reply. I needed this asap. Thanks!


Ps: here are all my codings:


<br />
// MediVisionView.cpp : implementation of the CMediVisionView class<br />
//<br />
<br />
#include "stdafx.h"<br />
#include "MediVision.h"<br />
#include "PatientDialogBox.h"<br />
#include "MediVisionDoc.h"<br />
#include "MediVisionView.h"<br />
#include "Glob.h"<br />
#include "Math.h"<br />
#include "Edit_Patient_Data.h"<br />
#include "Expand_Pixel.h"<br />
#include "Rows_Cols.h"<br />
<br />
#include <br />
#include <br />
<br />
typedef std::vector StringArray; //typedef vector of string type<br />
using namespace std; //do not need to prepend std:: to Standard Library<br />
<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
unsigned char *argbPixelsPtr;<br />
unsigned char *rgbPixelsPtr;<br />
unsigned int argbPixels[512][512];<br />
unsigned int argb256Pixels[256][256];<br />
unsigned int rgbPixels[512][512];<br />
unsigned int rgb256Pixels[256][256];<br />
unsigned int storeargbPixels[512][512];<br />
<br />
<br />
int *Bitmap_r, *Bitmap_g, *Bitmap_b;<br />
int *image[5], *store[5], *image256, *store256, *image512, *store512, *image32, *store32,*image16, *store16;<br />
int mouse1_x, mouse1_y, mouse2_x, mouse2_y; //Store mousedown and mouseup coordinate (For rectangle)<br />
int rows1,rows2,cols1,cols2;<br />
int clk_mouse_x, clk_mouse_y; //Store reference point wrt to the screen left hand corner <br />
int ref_selected_x, ref_selected_y; //Store the computed reference point wrt to the image left hand corner <br />
int ref_intensity; //Store Reference point intensity (for region growing) value <br />
int Grad_x, Grad_y, Grad_z; //For storing Gradient values during volume rendering<br />
<br />
<br />
short dcmPixel[480][262144];<br />
<br />
<br />
float alphaTable[262144];<br />
float luminanceTable[262144];<br />
float MidX, MidY, MidZ;<br />
float Translation[4][4];<br />
float Rotation[4][4];<br />
float pt_x[5], pt_y[5], pt_z[5];<br />
<br />
<br />
char UID[30];<br />
<br />
<br />
int *pixelvalue, maxpix;<br />
int box_x, box_y; // Co-ordinates of the top left hand corner of box with reference to image corner.<br />
CDC *pDC;<br />
HDC hdc;<br />
int n_rows, n_cols;<br />
int k = 0;<br />
int Expand_Pixel;<br />
int s, nCount;<br />
<br />
<br />
CString strAppDirectory;<br />
long position, sliceThickness_position,ImageNo_position,Axis_position,PixelSize_position;<br />
int ** region;<br />
int pass; // Number of times that ReadFile module is called<br />
// This is use for deleted the pointers as we want<br />
bool insert, rightbut;<br />
// do not want to delete the last set of image data of 3D maximum intensity option<br />
bool noFile, Flag3D; // Flag3D is a flag to indicate that the 3D maximum intensity option is selected<br />
bool box, ref_pt; //<------------------------<br />
<br />
<br />
// camera function<br />
int magnification;<br />
bool zoom, grid;<br />
<br />
bool eraser, leftbut;<br />
bool multiple_open;<br />
bool cancel1,cancel2;<br />
CPoint er_point;<br />
CPoint Anchor;<br />
FILE *fp, *fw, *fe; // File pointer<br />
<br />
char *st;<br />
<br />
bool edited;<br />
void SetClassificationTable();<br />
void DrawRectn();<br />
<br />
////////////////////////////Modified Variables(For Object Lining Menu)////////////////////////////////////<br />
//-----------New coding-------------//<br />
bool Rectn; //To define the Rectangular box item created.<br />
<br />
//int m1_x, m1_y, m2_x, m2_y; //Store mousedown and mouseup coordinate (For Rectangular box)<br />
<br />
int mouse_x, mouse_y; //Store reference point with correspond to the screen left hand corner <br />
<br />
int num; // number<br />
<br />
int r, c; //rows and column of Rectangular Box<br />
<br />
int max, min; //maximum and minimum of image<br />
<br />
int point_x, point_y; //Define the points inside the image<br />
<br />
int point_x1, point_y1; //Define the points inside the image<br />
<br />
int point_w1, point_z1;<br />
<br />
bool minflag, maxflag;<br />
<br />
int sg_length, sg_height; // Length and height of the Rectangular box<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
//--------------End of coding-----------------//<br />
<br />
// CMediVisionView<br />
<br />
IMPLEMENT_DYNCREATE(CMediVisionView, CView)<br />
BEGIN_MESSAGE_MAP(CMediVisionView, CView)<br />
//{{AFX_MSG_MAP(CMediVisionView)<br />
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)<br />
ON_WM_ERASEBKGND()<br />
ON_COMMAND(ID_3D_MAXIMUMINTENSITY, On3dMaximumintensity)<br />
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)<br />
ON_COMMAND(ID_3D_SURFACERENDERING, On3dSurfacerendering)<br />
ON_WM_LBUTTONDOWN()<br />
ON_WM_LBUTTONUP()<br />
ON_WM_MOUSEMOVE()<br />
ON_COMMAND(ID_SEGMENTATION_REGIONGROWING, OnSegmentationRegiongrowing)<br />
ON_WM_SETCURSOR()<br />
ON_COMMAND(ID_FILE_MULTIPLEOPEN, OnFileMultipleopen)<br />
ON_COMMAND(ID_RToolbar_3DIntensity, OnRToolbar3DIntensity)<br />
ON_COMMAND(ID_RToolbar_Multipleopen, OnRToolbarMultipleopen)<br />
ON_COMMAND(ID_RToolbar2_Region, OnRToolbar2Region)<br />
ON_COMMAND(ID_3D_VOLUMERENDERING, On3dVolumerendering)<br />
ON_COMMAND(ID_TOOLS_ERASER, OnToolsEraser)<br />
ON_COMMAND(ID_TOOLS_BOOLEAN, OnToolsBoolean)<br />
ON_COMMAND(ID_TOOLS_MAXIMATION, OnToolsMaximation)<br />
ON_COMMAND(ID_ERASER, OnEraser)<br />
ON_COMMAND(ID_TOOLS_PEN, OnToolsPen)<br />
ON_COMMAND(ID_PEN, OnPen)<br />
ON_COMMAND(ID_EDIT_PATIENT_DATA, OnEditPatientData)<br />
ON_COMMAND(ID_MORPHOLOFICAL, OnMorpholofical)<br />
ON_COMMAND(ID_ZOOM_2X, OnZoom2x)<br />
ON_COMMAND(ID_ZOOM_4X, OnZoom4x)<br />
ON_COMMAND(ID_TOOLS_EXPANSION, OnToolsExpansion)<br />
ON_COMMAND(ID_LINE_OBJECTS, OnLineObjects)<br />
ON_WM_RBUTTONDOWN()<br />
//}}AFX_MSG_MAP<br />
// Standard printing commands<br />
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)<br />
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)<br />
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)<br />
END_MESSAGE_MAP()<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
// CMediVisionView construction/destruction<br />
<br />
CMediVisionView::CMediVisionView()<br />
{<br />
// TODO: add construction code here<br />
m_File1 = _T(" ");<br />
pixelmax = 256;<br />
maxpix = 256;<br />
multiple_open = false;<br />
no_of_rows = 0;<br />
no_of_cols = 0;<br />
box = false;<br />
eraser = false;<br />
leftbut = false;<br />
ref_pt = false;<br />
MotionFix = 0;<br />
m_Dragging = false;<br />
Expand_Pixel = 0;<br />
<br />
<br />
//-------------New Coding----------------//<br />
Rectn = false; // Disables the drawing of the rectangle<br />
MDrag = false; //Disables the Dragging of the mouse<br />
Motion = 0; //Set the motion of the mouse to draw rectangle to none<br />
mini = 0;<br />
maxi=0;<br />
<br />
//---------------End of coding-------------//<br />
<br />
<br />
<br />
}<br />
<br />
CMediVisionView::~CMediVisionView()<br />
{<br />
// delete [] region;<br />
}<br />
<br />
BOOL CMediVisionView::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
// TODO: Modify the Window class or styles here by modifying<br />
// the CREATESTRUCT cs<br />
<br />
return CView::PreCreateWindow(cs);<br />
}<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
// CMediVisionView drawing<br />
<br />
<br />
void FrameLines(CDC *pDC) {<br />
<br />
// CPen newPen(PS_SOLID,pixelsize, colour);<br />
// CPen* pOldPen = pDC->SelectObject(&newPen);<br />
// pDC->MoveTo(x,y); // move current position of pen<br />
// pDC->LineTo(x+1,y+1);<br />
// pDC->SelectObject(pOldPen);// reset back the old pen object<br />
<br />
CBrush brush, *pOB;<br />
<br />
int xSize=::GetSystemMetrics(SM_CXSCREEN);<br />
int ySize=::GetSystemMetrics(SM_CYSCREEN);<br />
<br />
brush.CreateSolidBrush(RGB(210,220,205)); <br />
pOB = pDC->SelectObject(&brush);<br />
<br />
pDC->Rectangle(525, -1, 530, ySize);<br />
pDC->Rectangle(529, (ySize/2 - 45), xSize, (ySize/2-40));<br />
}<br />
<br />
<br />
<br />
void CMediVisionView::OnDraw(CDC* pDC)<br />
{<br />
CMediVisionDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
// TODO: add draw code for native data here<br />
<br />
<br />
if (First==TRUE) {<br />
First=FALSE;<br />
Draw(); // If it is the first time, use draw <br />
CClientDC ClientDC(this);<br />
FrameLines(&ClientDC);<br />
<br />
}<br />
else { <br />
ReDraw(); // To redraw<br />
}<br />
}<br />
<br />
void DrawBox(CDC *pdc,CPoint m_One, CPoint m_Two)<br />
{<br />
pdc->MoveTo(m_One);<br />
pdc->LineTo(m_One.x, m_Two.y);<br />
<br />
pdc->MoveTo(m_One);<br />
pdc->LineTo(m_Two.x, m_One.y);<br />
<br />
pdc->MoveTo(m_Two.x,m_One.y);<br />
pdc->LineTo(m_Two.x, m_Two.y);<br />
<br />
pdc->MoveTo(m_One.x,m_Two.y);<br />
pdc->LineTo(m_Two.x, m_Two.y);<br />
<br />
}<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
// CMediVisionView printing<br />
<br />
BOOL CMediVisionView::OnPreparePrinting(CPrintInfo* pInfo)<br />
{<br />
// default preparation<br />
return DoPreparePrinting(pInfo);<br />
}<br />
<br />
void CMediVisionView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)<br />
{<br />
// TODO: add extra initialization before printing<br />
}<br />
<br />
void CMediVisionView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)<br />
{<br />
// TODO: add cleanup after printing<br />
}<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
// CMediVisionView diagnostics<br />
<br />
#ifdef _DEBUG<br />
void CMediVisionView::AssertValid() const<br />
{<br />
CView::AssertValid();<br />
}<br />
<br />
void CMediVisionView::Dump(CDumpContext& dc) const<br />
{<br />
CView::Dump(dc);<br />
}<br />
<br />
CMediVisionDoc* CMediVisionView::GetDocument() // non-debug version is inline<br />
{<br />
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMediVisionDoc)));<br />
return (CMediVisionDoc*)m_pDocument;<br />
}<br />
#endif //_DEBUG<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
<br />
/* This routine(onFileOpen) is use for opening only 1 selected file. <br />
It will call ReadFile to read the Dicom file and display it.*/<br />
<br />
////////////////////////////////////////////////////////////////////////////<br />
CString file;<br />
<br />
void CMediVisionView::OnFileOpen() <br />
{<br />
<br />
// TODO: Add your command handler code here<br />
<br />
// static char BASED_CODE szFilter[] = "All Files (*.*)|*.*|Bitmap Files(*.bmp)| *.bmp|\<br />
// DICOM Files(*.dcm) | *.dcm";<br />
multiple_open=false;<br />
image_no=0;<br />
OpenFile(); <br />
}<br />
<br />
////////////////////////////////////////////////////////////////////<br />
/* These routines OnInitial Update to OnEraseBkgnd is <br />
used topaint the background Blue */<br />
///////////////////////////////////////////////////////////////////<br />
<br />
void CMediVisionView::OnInitialUpdate() <br />
{<br />
CView::OnInitialUpdate();<br />
<br />
// TODO: Add your specialized code here and/or call the base class<br />
SetBackgroundColor(RGB(50, 50, 50));<br />
CMediVisionDoc* pDoc = GetDocument();<br />
pDoc->SetPathName("LEO",TRUE);<br />
}<br />
<br />
void CMediVisionView::SetBackgroundColor(COLORREF crBackground)<br />
{<br />
m_crBackground = crBackground;<br />
if (m_wndbkBrush.GetSafeHandle())<br />
m_wndbkBrush.DeleteObject();<br />
m_wndbkBrush.CreateSolidBrush(m_crBackground);<br />
}<br />
<br />
<br />
BOOL CMediVisionView::OnEraseBkgnd(CDC* pDC) <br />
{<br />
// TODO: Add your message handler code here and/or call default<br />
CRect rect;<br />
GetClientRect(rect);<br />
pDC->FillRect(&rect, &m_wndbkBrush);<br />
return TRUE;<br />
<br />
}<br />
<br />
/////////////////////////////////////////////////////////////////////<br />
/* This routine ReDraw is use to refresh the screen after minimise.<br />
The routine differentiates drawing of 512x512 or 256x256 image data<br />
For 256x256, it allows multiple images to be screen. For 512x512,<br />
only 1 image is shown. This routine is called by OnDraw(). */<br />
////////////////////////////////////////////////////////////////////<br />
<br />
void CMediVisionView::ReDraw()<br />
{<br />
int row, col;<br />
int p, q, n;<br />
int cx_position[6], cy_position[6]; <br />
unsigned int data;<br />
<br />
BITMAPINFOHEADER infoHeader;<br />
infoHeader.biSize = sizeof(BITMAPINFOHEADER);<br />
infoHeader.biWidth = n_cols;<br />
infoHeader.biHeight = n_rows;<br />
infoHeader.biPlanes=1;<br />
infoHeader.biBitCount= 24;<br />
infoHeader.biCompression=0;<br />
infoHeader.biSizeImage=0;<br />
infoHeader.biXPelsPerMeter=0;<br />
infoHeader.biYPelsPerMeter=0;<br />
infoHeader.biClrUsed=0;<br />
infoHeader.biClrImportant=0;<br />
<br />
int xSize=::GetSystemMetrics(SM_CXSCREEN)-80;<br />
int ySize=::GetSystemMetrics(SM_CYSCREEN);<br />
<br />
CClientDC ClientDC(this); // Draw the Frame Lines first<br />
FrameLines(&ClientDC);<br />
<br />
if (n_rows== 256 && multiple_open) {<br />
if(image_no == 1) {<br />
cx_position[1] = ((xSize/2) - (n_cols/2));<br />
cy_position[1] = ((ySize/2) - (n_rows/2)) - 70;<br />
}<br />
else if(image_no == 2) {<br />
cx_position[1] = ((xSize/2) - (n_cols+10));<br />
cy_position[1] = ((ySize/2) - (n_rows/2)) - 70;<br />
cx_position[2] = ((xSize/2) + 10);<br />
cy_position[2] = ((ySize/2) - (n_rows/2)) - 70;<br />
}<br />
else if(image_no == 3) {<br />
cx_position[1] = 5;<br />
cy_position[1] = ((ySize/2) - (n_rows/2)) - 70;<br />
cx_position[2] = 5 + n_cols + 5;<br />
cy_position[2] = ((ySize/2) - (n_rows/2)) - 70;<br />
cx_position[3] = 5 + n_cols + 5 + n_cols + 5;<br />
cy_position[3] = ((ySize/2) - (n_rows/2)) - 70;<br />
}<br />
else if(image_no == 4) {<br />
cx_position[1] = ((xSize/2) - (n_cols+20));<br />
cy_position[1] = ((ySize/2) - (n_rows+20)) - 50;<br />
cx_position[2] = ((xSize/2) +20);<br />
cy_position[2] = ((ySize/2) - (n_rows+20)) - 50;<br />
cx_position[3] = ((xSize/2) - (n_cols+20));<br />
cy_position[3] = ((ySize/2) +10) - 70;<br />
cx_position[4] = ((xSize/2) +20);<br />
cy_position[4] = ((ySize/2) +10) - 70;<br />
}<br />
<br />
for(int s=1;s<=image_no;s++) {<br />
n = 0;<br />
for(int p=0;p for(int q=0;q data = image256[n];<br />
if (data <= 0) {<br />
argb256Pixels[p][q] = (unsigned int)(0 | 0 | 0 | 0);<br />
}<br />
else {<br />
argb256Pixels[p][q] = (unsigned int)(data<<24 | data<<16 | data<<8 | data);<br />
}<br />
n++;<br />
}<br />
}<br />
<br />
argbPixelsPtr = (unsigned char *) argb256Pixels;<br />
rgbPixelsPtr = (unsigned char *) rgb256Pixels;<br />
<br />
for (row=0; row for(col=0; col *rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
argbPixelsPtr++;<br />
} <br />
}<br />
<br />
StretchDIBits(hdc, cx_position[s], cy_position[s], n_rows, n_cols, 0, 0, n_rows, n_cols, rgb256Pixels,(BITMAPINFO*) &infoHeader, 0, SRCCOPY); <br />
}<br />
}<br />
<br />
<br />
else if (n_rows== 256 && !multiple_open) {<br />
n = 0;<br />
for (p=0; p for (q=0; q data = image256[n];<br />
if (data <= 0) {<br />
argb256Pixels[p][q] = (unsigned int)(0 | 0 | 0 | 0);<br />
}<br />
else {<br />
argb256Pixels[p][q] = (unsigned int)(data<<24 | data<<16 | data<<8 | data);<br />
}<br />
n++;<br />
}<br />
}<br />
<br />
argbPixelsPtr = (unsigned char *) argb256Pixels;<br />
rgbPixelsPtr = (unsigned char *) rgb256Pixels;<br />
<br />
for (row=0; row for(col=0; col *rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
argbPixelsPtr++;<br />
} <br />
}<br />
StretchDIBits(hdc, posx256, posy256, n_rows, n_cols, 0, 0, n_rows, n_cols, rgb256Pixels,(BITMAPINFO*) &infoHeader, 0, SRCCOPY); <br />
<br />
}<br />
<br />
else if(n_rows==512){<br />
n = 0;<br />
for (p=0; p for (q=0; q data = image512[n];<br />
if (data <=0) {<br />
argbPixels[p][q] = (unsigned int)(0 | 0 | 0 | 0); <br />
}<br />
else {<br />
argbPixels[p][q] = (unsigned int)(data<<24 | data<<16 | data<<8 | data);<br />
}<br />
n++;<br />
}<br />
}<br />
<br />
argbPixelsPtr = (unsigned char *) argbPixels;<br />
rgbPixelsPtr = (unsigned char *) rgbPixels;<br />
<br />
for (row=0; row for(col=0; col *rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
argbPixelsPtr++;<br />
} <br />
} <br />
StretchDIBits(hdc, posx512,posy512, n_rows, n_cols, 0, 0, n_rows, n_cols, rgbPixels,(BITMAPINFO*) &infoHeader, 0, SRCCOPY); <br />
} <br />
}<br />
<br />
void CMediVisionView::On3dMaximumintensity() <br />
{<br />
// TODO: Add your command handler code here<br />
<br />
static char BASED_CODE szFilter[] = "All Files (*.*)|*.*|Dicom Files (*.dcm)|*.dcm||";<br />
CFileDialog dlg( TRUE, NULL, NULL, OFN_ALLOWMULTISELECT | OFN_EXPLORER, szFilter);<br />
<br />
// dlg.m_ofn.lpstrInitialDir = "d:\\bmestudent\\dicom project\\dicom"; //testing purpose<br />
Flag3D = true;<br />
multiple_open = false;<br />
pass = 0;<br />
DWORD MAXFILE = 13562; //5562 is the max<br />
dlg.m_ofn.nMaxFile = MAXFILE;<br />
<br />
char* buffer = new char[MAXFILE];<br />
<br />
dlg.m_ofn.lpstrFile = buffer;<br />
dlg.m_ofn.lpstrFile[0] = NULL;<br />
<br />
int iReturn = dlg.DoModal();<br />
<br />
nCount = 0; // Count the number of files open<br />
<br />
if (iReturn == 1) {<br />
POSITION pos = dlg.GetStartPosition();<br />
POSITION pos1 = dlg.GetStartPosition();<br />
if (pos1) {<br />
do {<br />
std::string Pathname;<br />
Pathname = dlg.GetNextPathName(pos1);<br />
nCount++; // Count the number of files selected<br />
} while (pos1); <br />
}<br />
<br />
if(pos) {<br />
<br />
image_no=1;<br />
<br />
do {<br />
<br />
m_File1 = dlg.GetNextPathName(pos);<br />
if ((fp = fopen(m_File1, "rb")) == NULL) {<br />
noFile = true;<br />
}<br />
else {<br />
noFile = false;<br />
}<br />
<br />
ReadFile();<br />
<br />
// pDC = GetDC(); <br />
// hdc=pDC->GetSafeHdc();<br />
// Draw();<br />
<br />
if (Flag3D == true) {<br />
delete [] pixelvalue;<br />
if (pass < nCount) {<br />
if (n_rows == 512) {<br />
delete [] image512; // Delete storage due to reptitive creation in the 3Dmaximum intensity<br />
delete [] store512;<br />
}<br />
else if (n_rows == 256 && !multiple_open) {<br />
delete [] image256; // Only the first image array parameter was used for 3D display, so delete it<br />
delete [] store256;<br />
}<br />
else if (n_rows == 256 && multiple_open) {<br />
delete [] image[image_no];<br />
delete [] store[image_no];<br />
}<br />
}<br />
}<br />
<br />
} while(pos); <br />
<br />
}<br />
<br />
if (no_of_rows==256) {<br />
image256=new int [no_of_rows*no_of_cols]; // Creating memory for storing an array of image data<br />
store256=new int [no_of_rows*no_of_cols];<br />
}<br />
else {<br />
image512 = new int [no_of_rows*no_of_cols];<br />
store512 = new int [no_of_rows*no_of_cols];<br />
}<br />
<br />
Compute_Vol_Max_Intensity();<br />
Invalidate(); //refresh window<br />
UpdateWindow();<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
Draw();<br />
<br />
} <br />
}<br />
<br />
void CMediVisionView::ReadFile()<br />
{<br />
<br />
int i, loop, n, p,q;<br />
short tag[2];<br />
long num;<br />
char a;<br />
char VR[2], DICM[5], *string;//, *pixel_size;<br />
int iLength;<br />
short ValueLength; <br />
short ValueField;<br />
short ReservedField; // For OB, OW, SQ and UN data type only<br />
unsigned short sdata;<br />
unsigned int idata;<br />
bool flag, pixelread;<br />
<br />
// if ((fw = fopen(strAppDirectory + "\\test.dcm","w+b")) == NULL)<br />
if ((fw = fopen("test.dcm","w+b")) == NULL) <br />
AfxMessageBox("Cannot open binary file for some reason");<br />
<br />
if (noFile == false) {<br />
flag = true;<br />
pixelread = true;<br />
pixelmax = 256;<br />
n=0;<br />
fseek(fp, 128, 0); // Skip 128 Bytes <br />
fseek(fw, 128, 0);<br />
fgets(DICM,5,fp);<br />
<br />
//--READING OF TAGS IN DICOM FILE ------------------------------------<br />
<br />
if (strcmp(DICM, "DICM")!=0) { // Not the latest DICM file<br />
fseek(fp, 0, 0); // Push the File pointer to the beginning of file<br />
fseek(fw, 0, 0); <br />
string=new char[20]; // For deletion purpose<br />
strcpy(UID, "1.2.840.10008.1.2"); <br />
}<br />
else<br />
fwrite(DICM, sizeof(char), 4, fw);<br />
<br />
while (flag == true) {<br />
for (i=0; i<2;i++) { // Read Tag - 2 bytes<br />
fread(&tag[i], sizeof(unsigned short), 1, fp); // Ordered pair of 16-bit unsigned int <br />
fwrite(&tag[i], sizeof(unsigned short), 1, fw);<br />
}<br />
<br />
//--READING AND WRITING DATA ELEMENT OF HEADER FOR SAVING------------------------------------<br />
<br />
if (tag[0] < 32736) {<br />
if (tag[0]==2) { // For tag 2 only<br />
strcpy(VR, " ");<br />
fgets(VR,3,fp); // Read Value Representation<br />
fwrite(VR, sizeof(char), 2, fw);<br />
<br />
if (tag[1]==16) { // Read the Transfer Syntax data UID<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
<br />
fgets(UID,ValueLength+1,fp);<br />
fwrite(UID, sizeof(char), ValueLength, fw);<br />
}<br />
else {<br />
if (strcmp(VR, "UL")==0) {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&ValueField, sizeof(unsigned long), 1, fp); // Read Value Field (4 bytes as indicated by VL)<br />
fwrite(&ValueField, sizeof(unsigned long), 1, fw);<br />
}<br />
<br />
else if (strcmp(VR,"OB")==0) {<br />
fread(&ReservedField, sizeof(unsigned short), 1, fp);// Read Reserved Field<br />
fwrite(&ReservedField, sizeof(unsigned short), 1, fw);<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&ValueField, sizeof(unsigned long), 1, fp); // Value Field (4 bytes as indicated by VL)<br />
fwrite(&ValueField, sizeof(unsigned long), 1, fw);<br />
}<br />
<br />
else if (strcmp(VR, "UI")==0 || strcmp(VR, "SH")==0 || strcmp(VR, "AE")==0) {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
string=new char[ValueLength+1];<br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char),ValueLength,fw);<br />
}<br />
<br />
else { // Read Implicit CS<br />
num = (int)VR[0];<br />
fgetc(fp);<br />
<br />
for (loop=0; loop a = fgetc(fp);<br />
fputc(a,fw);<br />
}<br />
}<br />
}<br />
}<br />
<br />
else { // else tag[0] not equals to 2<br />
//------------------------------------------------------------------------------<br />
if (strcmp(UID, "1.2.840.10008.1.2.1")==0) {<br />
strcpy(VR, " ");<br />
fgets(VR,3,fp);<br />
fwrite(VR, sizeof(char), 2, fw);<br />
<br />
if (tag[0]==40) {<br />
if (tag[1]==16) { // Reading of number of pixel rows<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&sdata, sizeof(unsigned short), 1, fp); // Read Value Field (4 bytes as indicated by VL) printf("\tField=%d\n", ValueField);<br />
fwrite(&sdata, sizeof(unsigned short), 1, fw);<br />
no_of_rows = sdata;<br />
n_rows = no_of_rows;<br />
}<br />
else if (tag[1]==17) { // Reading of number of pixel cols<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&sdata, sizeof(unsigned short), 1, fp); // Read Value Field (4 bytes as indicated by VL) printf("\tField=%d\n", ValueField);<br />
fwrite(&sdata, sizeof(unsigned short), 1, fw);<br />
no_of_cols = sdata;<br />
n_cols = no_of_cols;<br />
}<br />
else if (tag[1]==263) { // Reading of maximum pixel value<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&sdata, sizeof(unsigned short), 1, fp); // Read Value Field (4 bytes as indicated by VL) printf("\tField=%d\n", ValueField);<br />
fwrite(&sdata, sizeof(unsigned short), 1, fw);<br />
if (sdata <= 5) pixelmax=256; // If no pixelmax data, set it of 256<br />
else pixelmax = sdata;<br />
}<br />
else {<br />
if (strcmp(VR, "UL") ==0) {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); <br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&ValueField, sizeof(unsigned long), 1, fp);<br />
fwrite(&ValueField, sizeof(unsigned long), 1, fw);<br />
}<br />
else if (strcmp(VR,"FL")==0) {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&iLength, sizeof(unsigned int), 1, fp); // Read Value Field (4 bytes as indicated by VL) <br />
fwrite(&iLength, sizeof(unsigned int), 1, fp);<br />
} <br />
else if (strcmp(VR, "OB") ==0) {<br />
fread(&ReservedField, sizeof(unsigned short), 1, fp);<br />
fwrite(&ReservedField, sizeof(unsigned short), 1, fw);<br />
fread(&iLength, sizeof(unsigned int), 1, fp);<br />
fwrite(&iLength, sizeof(unsigned int), 1, fw);<br />
for (int te=0; te a=getc(fp);<br />
putc(a,fw);<br />
}<br />
}<br />
<br />
else if (strcmp(VR, "SQ") ==0) {<br />
fread(&ReservedField, sizeof(unsigned short), 1, fp);<br />
fwrite(&ReservedField, sizeof(unsigned short), 1, fw);<br />
fread(&iLength, sizeof(unsigned int), 1, fp);<br />
fwrite(&iLength, sizeof(unsigned int), 1, fw);<br />
for (int te=0; te a=getc(fp);<br />
putc(a,fw);<br />
}<br />
}<br />
else {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); <br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
string=new char[ValueLength+1]; // Reading Value Length<br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
}<br />
}<br />
} <br />
<br />
else {<br />
<br />
if (strcmp(VR, "UL") ==0) {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); <br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&ValueField, sizeof(unsigned long), 1, fp);<br />
fwrite(&ValueField, sizeof(unsigned long), 1, fw); <br />
}<br />
else if (strcmp(VR, "OB") ==0) {<br />
fread(&ReservedField, sizeof(unsigned short), 1, fp);<br />
fwrite(&ReservedField, sizeof(unsigned short), 1, fw);<br />
fread(&iLength, sizeof(unsigned int), 1, fp);<br />
fwrite(&iLength, sizeof(unsigned int), 1, fw);<br />
for (int te=0; te a=getc(fp);<br />
putc(a,fw);<br />
}<br />
}<br />
else if (strcmp(VR,"FL")==0) {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
fread(&iLength, sizeof(unsigned int), 1, fp); // Read Value Field (4 bytes as indicated by VL) <br />
fwrite(&iLength, sizeof(unsigned int), 1, fw);<br />
}<br />
else if (strcmp(VR, "SQ") ==0) {<br />
fread(&ReservedField, sizeof(unsigned short), 1, fp);<br />
fwrite(&ReservedField, sizeof(unsigned short), 1, fw);<br />
fread(&iLength, sizeof(unsigned int), 1, fp);<br />
fwrite(&iLength, sizeof(unsigned int), 1, fw);<br />
<br />
for (int te=0; te a=fgetc(fp);<br />
fputc(a,fw);<br />
}<br />
}<br />
else {<br />
fread(&ValueLength, sizeof(unsigned short), 1, fp); <br />
fwrite(&ValueLength, sizeof(unsigned short), 1, fw);<br />
string=new char[ValueLength+1]; // Reading Value Length<br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
}<br />
}<br />
}<br />
//----------------------------------------------------------------------------<br />
else if (strcmp(UID, "1.2.840.10008.1.2")==0) {<br />
fread(&ValueLength, sizeof(unsigned int), 1, fp); // Read Value Length (VL) - 16 bits<br />
fwrite(&ValueLength, sizeof(unsigned int), 1, fw);<br />
<br />
if (tag[0]==40) {<br />
if (tag[1] == 0x30) {<br />
<br />
PixelSize_position =ftell(fp);<br />
string=new char[ValueLength+1];<br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
}<br />
else if (tag[1]==16) { // Reading of number of pixel rows <br />
fread(&sdata, sizeof(unsigned short), 1, fp); // Read Value Field (4 bytes as indicated by VL) printf("\tField=%d\n", ValueField);<br />
fwrite(&sdata, sizeof(unsigned short), 1, fw);<br />
no_of_rows = sdata;<br />
n_rows = no_of_rows;<br />
}<br />
else if (tag[1]==17) { // Reading of number of pixel cols<br />
fread(&sdata, sizeof(unsigned short), 1, fp); // Read Value Field (4 bytes as indicated by VL) printf("\tField=%d\n", ValueField);<br />
fwrite(&sdata, sizeof(unsigned short), 1, fw);<br />
no_of_cols = sdata;<br />
n_cols = no_of_cols;<br />
}<br />
else if (tag[1]==263) { // Reading of maximum pixel value<br />
fread(&sdata, sizeof(unsigned short), 1, fp); // Read Value Field (4 bytes as indicated by VL) printf("\tField=%d\n", ValueField);<br />
fwrite(&sdata, sizeof(unsigned short), 1, fw);<br />
if (sdata <= 5) pixelmax=256; // If no pixelmax data, set it of 256<br />
else pixelmax = sdata;<br />
}<br />
else {<br />
string=new char[ValueLength+1]; <br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
}<br />
}<br />
<br />
<br />
<br />
else if ( tag[0] == 0x18 && tag[1] == 0x50 ) {<br />
sliceThickness_position = ftell(fp);<br />
string=new char[ValueLength+1]; <br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
<br />
}<br />
else if ( tag[0] == 0x20 && tag[1] == 0x13) {<br />
ImageNo_position = ftell(fp);<br />
string=new char[ValueLength+1]; <br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
<br />
}<br />
else if ( tag[0] == 0x20 && tag[1] == 0x32) { <br />
Axis_position = ftell(fp);<br />
string=new char[ValueLength+1]; <br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
<br />
}<br />
<br />
<br />
<br />
<br />
else if (tag[0] == 0x817) {<br />
fseek(fp, ValueLength, SEEK_CUR);<br />
fseek(fw, ValueLength, SEEK_CUR);<br />
}<br />
else {<br />
string=new char[ValueLength+1]; // Reading Value Length<br />
fgets(string,ValueLength+1,fp);<br />
fwrite(string, sizeof(char), ValueLength, fw);<br />
}<br />
} // End of the Transfer Syntax UID if block<br />
} // End of the tag[0]=2 if block<br />
}<br />
// -----------Read pixel data ---------------------------------------<br />
<br />
else {<br />
<br />
if (no_of_rows == 512) {<br />
fread(&idata, sizeof(unsigned int), 1, fp);<br />
fwrite(&idata, sizeof(unsigned int), 1, fw);<br />
fread(&idata, sizeof(unsigned int), 1, fp);<br />
fwrite(&idata, sizeof(unsigned int), 1, fw);<br />
}<br />
else if (no_of_rows == 256) {<br />
fread(&idata, sizeof(unsigned int), 1, fp);<br />
fwrite(&idata, sizeof(unsigned int), 1, fw);<br />
fread(&idata, sizeof(unsigned int), 1, fp);<br />
fwrite(&idata, sizeof(unsigned int), 1, fw);<br />
}<br />
<br />
position = ftell(fw);<br />
fclose (fw);<br />
<br />
pixelvalue = new int[no_of_rows*no_of_cols];<br />
if (no_of_rows==256 && multiple_open) {<br />
image[image_no]=new int [no_of_rows*no_of_cols]; // Creating memory for storing an array of image data<br />
store[image_no]=new int [no_of_rows*no_of_cols];<br />
}<br />
else if (no_of_rows==256 && !multiple_open){<br />
image256=new int [no_of_rows*no_of_cols]; // Creating memory for storing an array of image data<br />
store256=new int [no_of_rows*no_of_cols];<br />
}<br />
else {<br />
image512 = new int [no_of_rows*no_of_cols];<br />
store512 = new int [no_of_rows*no_of_cols];<br />
}<br />
while (pixelread==true) {<br />
fread(&sdata, sizeof(unsigned short), 1, fp); // Value Field (4 bytes as indicated by VL)<br />
<br />
if (sdata>5000) <br />
sdata = 0; // pixel data too large, probably due to noise<br />
pixelmax = (sdata > pixelmax)? sdata : pixelmax;<br />
maxpix = pixelmax;<br />
pixelvalue[n] = sdata;<br />
<br />
n++; // Increment the reading by 1<br />
<br />
if (n==(no_of_rows*no_of_cols)) // if finish reading the pixel data<br />
pixelread=false;<br />
}<br />
<br />
flag=false;<br />
}<br />
} // end of while loop<br />
<br />
fclose (fp);<br />
}<br />
<br />
<br />
n=0;<br />
for (p=0; p for (q=0; q pixelvalue[n] = ((float)pixelvalue[n]/(float)(pixelmax+1))*256;<br />
if (Flag3D==true) dcmPixel[pass][n] = pixelvalue[n]; <br />
if (n_rows==256 && multiple_open) {<br />
image[image_no][n]=pixelvalue[n]; // Store images data (working copy)<br />
store[image_no][n]=pixelvalue[n]; // Duplicate the image data<br />
}<br />
else if (n_rows==256 && !multiple_open) {<br />
image256[n]=pixelvalue[n]; // Store images data (working copy)<br />
store256[n]=pixelvalue[n]; // Duplicate the image data<br />
}<br />
else {<br />
image512[n] = pixelvalue[n];<br />
store512[n]=pixelvalue[n];<br />
}<br />
n++;<br />
}<br />
}<br />
<br />
pass++; // use for keeping track of the number of times<br />
<br />
// the pointers of image512, store512, etc short of the last pass.<br />
delete string;<br />
return;<br />
}<br />
<br />
<br />
void CMediVisionView::Compute_Vol_Max_Intensity()<br />
{<br />
int x1, y1;<br />
int i,j;<br />
<br />
//---------------------------------------------------------<br />
<br />
x1 = 0;<br />
y1 = no_of_rows - 1;<br />
<br />
if (no_of_rows==256) {<br />
for(i=0;i image256[i]=0;<br />
for(j=0;j image256[i] = <br />
(dcmPixel[j][i] > image256[i] ? dcmPixel[j][i] : image256[i]);<br />
store256[i] = image256[i];<br />
}<br />
}<br />
}<br />
else {<br />
for(i=0;i image512[i]=0;<br />
for(j=0;j<br />
if (dcmPixel[j][i] > 0) {<br />
image512[i] = <br />
(dcmPixel[j][i] > image512[i] ? dcmPixel[j][i] : image512[i]);<br />
store512[i]=image512[i];<br />
}<br />
<br />
}<br />
}<br />
}<br />
<br />
//---------------------------------------------------------------<br />
/* <br />
pt_x[2] = (float)(n_rows-1)/2.0; // Compute the centriod of volume data<br />
pt_y[2] = (float)(n_cols-1)/2.0;<br />
pt_z[2] = (float)(nCount-1)/2.0;<br />
<br />
float *view_x_plane = new float[n_rows*n_cols]; // create view plane;<br />
float *view_y_plane = new float[n_rows*n_cols];<br />
float *view_z_plane = new float[n_rows*n_cols];<br />
float *Translate_x = new float[n_rows*n_cols];<br />
float *Translate_y = new float[n_rows*n_cols];<br />
float *Translate_z = new float[n_rows*n_cols];<br />
<br />
// Generate the co-ordinates of the viewing plane<br />
<br />
x1 = 0;<br />
y1 = n_rows-1;<br />
<br />
for (point_no=0; point_no view_x_plane[point_no] = x1; // The x co-ordinate of the point is view_x_plane [point_no] while the <br />
view_y_plane[point_no] = y1; // the y_co-ordinate of the point is view_y_plane [point_no];<br />
view_z_plane[point_no] = 0; // The points are number left-right, top-down. point 0 is the top left hand corner<br />
<br />
x1++;<br />
if ((x1%n_cols) == 0) { // Used for numbering of the points on the view-plane<br />
x1=0;<br />
y1--;<br />
}<br />
}<br />
<br />
MidX= (n_cols-1.0)/2.0; // Mid-point of view plane<br />
MidY= (n_rows-1.0)/2.0; <br />
MidZ= 0;<br />
<br />
Translation[0][0] = 1;<br />
Translation[0][1] = 0;<br />
Translation[0][2] = 0;<br />
Translation[0][3] = -((n_cols - 1.0)/2.0);<br />
Translation[1][0] = 0;<br />
Translation[1][1] = 1;<br />
Translation[1][2] = 0;<br />
Translation[1][3] = -((n_rows - 1.0)/2.0);<br />
Translation[2][0] = 0;<br />
Translation[2][1] = 0;<br />
Translation[2][2] = 1;<br />
Translation[2][3] = (nCount-1.0)/2.0;<br />
Translation[3][3] = 1;<br />
<br />
// Perform Translation by centroid value <br />
<br />
for (point_no=0; point_no view_x_plane[point_no] = view_x_plane[point_no] + Translation[0][3]; <br />
view_y_plane[point_no] = view_y_plane[point_no] + Translation[1][3];<br />
view_z_plane[point_no] = view_z_plane[point_no] + Translation[2][3];<br />
}<br />
<br />
// Perform Rotation about X axis<br />
<br />
Rotation[0][0] = 1;<br />
Rotation[0][1] = 0;<br />
Rotation[0][2] = 0;<br />
Rotation[0][3] = -((n_cols - 1.0)/2.0);<br />
Rotation[1][0] = 0;<br />
Rotation[1][1] = 1;<br />
Rotation[1][2] = 0;<br />
Rotation[1][3] = -((n_rows - 1.0)/2.0);<br />
Rotation[2][0] = 0;<br />
Rotation[2][1] = 0;<br />
Rotation[2][2] = 1;<br />
Rotation[2][3] = (nCount-1.0)/2.0;<br />
Rotation[3][3] = 1;<br />
<br />
delete [] newPixel;<br />
delete [] view_x_plane;<br />
delete [] view_y_plane;<br />
delete [] view_z_plane;<br />
delete [] Translate_x;<br />
delete [] Translate_y;<br />
delete [] Translate_z;<br />
*/<br />
return;<br />
}<br />
<br />
void CMediVisionView::OnFileSaveAs() <br />
{<br />
// TODO: Add your command handler code here<br />
FILE *fs;<br />
<br />
int n;<br />
unsigned short sdata;<br />
<br />
static char BASED_CODE szFilter[] = "DICOM Files (*.dcm)|*.dcm|All Files (*.*)|*.*||"; <br />
CFileDialog dlg_save_as(FALSE, "dcm", NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilter);<br />
<br />
if(dlg_save_as.DoModal() == IDOK) {<br />
// fs = fopen(strAppDirectory + "\\test.dcm","a+b");<br />
fs = fopen("test.dcm","a+b");<br />
fseek(fs , position, 0);<br />
<br />
for (n=0; n if(n_rows == 256) {<br />
sdata = image256[n]*((float)maxpix/256.0f); <br />
}<br />
else {<br />
sdata = image512[n]*((float)maxpix/256.0f); //Rescale back into original form<br />
}<br />
fwrite(&sdata, sizeof(unsigned short), 1, fs); //write in new pixel data<br />
}<br />
<br />
fclose (fs);<br />
// MoveFile(strAppDirectory + "\\test.dcm",dlg_save_as.GetPathName());<br />
MoveFile( "test.dcm",dlg_save_as.GetPathName());<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
<br />
void CMediVisionView::On3dSurfacerendering() <br />
{<br />
// TODO: Add your command handler code here<br />
int x1, y1;<br />
int i,j;<br />
<br />
//---------------------------------------------------------<br />
<br />
x1 = 0;<br />
y1 = no_of_rows - 1;<br />
<br />
if (no_of_rows==256) {<br />
<br />
j=0;<br />
for(i=0;i image256[i]=0;<br />
for (j=0; j if (dcmPixel[j][i]>10) {<br />
image256[i] = dcmPixel[j][i]; <br />
store256[i] = image256[i];<br />
break;<br />
}<br />
}<br />
}<br />
}<br />
<br />
else {<br />
<br />
j=0;<br />
for(i=0;i image512[i]=0;<br />
for (j=0; j if (dcmPixel[j][i]>0) {<br />
image512[i] = dcmPixel[j][i];<br />
store512[i] = image512[i];<br />
break;<br />
}<br />
} <br />
} <br />
}<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
Draw();<br />
return;<br />
}<br />
<br />
void CMediVisionView::OnLButtonDown(UINT nFlags, CPoint point) <br />
{<br />
<br />
<br />
// TODO: Add your message handler code here and/or call default<br />
if (box) {<br />
m_PointOrigin = point;<br />
mouse1_x = point.x;<br />
mouse1_y = point.y;<br />
m_Dragging = true;<br />
<br />
}<br />
<br />
if (ref_pt && !box) { // If the mouse is press down set click <br />
ref_pt = false;<br />
clk_mouse_x = point.x; // Find the reference point position<br />
clk_mouse_y = point.y;<br />
Segment_Region();// Segmentation is called only after reference pt has been selected<br />
<br />
}<br />
<br />
//----------------------New coding-------------------------------------//<br />
//when left Button of the Mouse is pressed down//<br />
<br />
if (Rectn) { //Rectn is true<br />
<br />
m_PO = point; //Assign co-ordinates to m_PO<br />
m1_x = point.x; //Assign co-ordinate x to m1_x<br />
m1_y = point.y; //Assign Co-ordinate y to m1_y<br />
MDrag = true; //Activates Dragging of the rectangular box by the mouse<br />
<br />
}<br />
<br />
if (!Rectn) { // If not Rectn, the mouse is pressed down and set click! <br />
//Disables the reference point <br />
mouse_x = point.x; // Find the reference point position<br />
mouse_y = point.y; <br />
<br />
<br />
}<br />
<br />
//--------------------------------------------------------------------//<br />
<br />
<br />
if(eraser==true) { //if eraser is selected<br />
leftbut=true;<br />
}<br />
<br />
if(insert==true) //if insert is selected<br />
{ <br />
rightbut=true;<br />
}<br />
<br />
CView::OnLButtonDown(nFlags, point);<br />
}<br />
<br />
void CMediVisionView::OnLButtonUp(UINT nFlags, CPoint point) <br />
{<br />
// TODO: Add your message handler code here and/or call default<br />
if (m_Dragging) {<br />
mouse2_x = point.x;<br />
mouse2_y = point.y;<br />
<br />
box = false;<br />
m_Dragging = false;<br />
MotionFix=0;<br />
ref_pt = true; // Set the reference point flag is true only box has been drawn<br />
}<br />
<br />
<br />
//----------------------------------New Coding---------------------------------//<br />
//When left button of the mouse is released//<br />
if (MDrag) {<br />
//m2_x = point.x; //assign the coordinate of position x clicked by mouse to point x<br />
//m2_y = point.y; //assign the coordinate of position y clicked by mouse to point y<br />
<br />
Rectn = false; //disables drawing of rectangle<br />
MDrag = false; //disables Mouse dragging <br />
Motion =0; //set the motion of the mouse to draw the rectangle to none <br />
AreaSegmentation(); // Area Segmentation( ) is called when reference point has been selected<br />
MessageBox("Pls Right-Click to find the minimum point WITHIN the box!!");<br />
minflag = true; //Right-click to set the minimum point within the rectangle box<br />
}<br />
<br />
//-----------------------------------------------------------------------------//<br />
<br />
<br />
zoom = false;<br />
leftbut = false;<br />
<br />
eraser = false;<br />
leftbut = false;<br />
insert = false;<br />
rightbut = false;<br />
<br />
<br />
CView::OnLButtonUp(nFlags, point);<br />
}<br />
<br />
void CMediVisionView::onmousemove(UINT nFlags, CPoint point) <br />
{<br />
// TODO: Add your message handler code here and/or call default<br />
int cur_pos_x, cur_pos_y;<br />
int n;<br />
<br />
if(eraser==true) { // For erasing only<br />
if(leftbut==true){<br />
er_point = point;<br />
<br />
cur_pos_x = er_point.x - posx512; // Compute the current eraser point position<br />
cur_pos_y = er_point.y - posy512;<br />
n = (512-(cur_pos_y))*512 + cur_pos_x; // Translate it to the image pixel n <br />
<br />
for (int i=0; i<7; i++) {<br />
image512[n+i] = 0; // Delete for 7 pixels horizontal<br />
image512[(n-512)+i] =0; // Delete 2nd rows each time<br />
image512[(n-512*2)+i]=0; // Delete 3rd row also<br />
image512[(n-512*3)+i]=0;<br />
image512[(n-512*4)+i]=0;<br />
image512[(n-512*5)+i]=0;<br />
image512[(n-512*6)+i]=0;<br />
<br />
store512[n+i] = 0;<br />
store512[(n-512)+i] = 0;<br />
store512[(n-512*2)+i] = 0;<br />
store512[(n-512*3)+i] = 0;<br />
store512[(n-512*4)+i] = 0;<br />
store512[(n-512*5)+i] = 0;<br />
store512[(n-512*6)+i] = 0;<br />
<br />
}<br />
<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
<br />
Draw();<br />
}<br />
}<br />
/*else */if(insert==true) // For pen only<br />
{ <br />
if(rightbut==true)<br />
{<br />
// pen for image size 256 by 256<br />
if (no_of_rows == 256)<br />
{<br />
er_point = point;<br />
<br />
cur_pos_x = er_point.x - posx256; // Compute the current eraser point position<br />
cur_pos_y = er_point.y - posy256;<br />
n = (256-(cur_pos_y))*256 + cur_pos_x; // Translate it to the image pixel n <br />
<br />
for (int i=0; i<2; i++) <br />
{<br />
image256[n+i] = 255; // Delete for 2 pixels horizontal<br />
image256[(n-256)+i] =255; // Delete 2nd rows each time<br />
// image256[(n-256*2)+i]=255; // Delete 3rd row also<br />
// image256[(n-256*3)+i]=255;<br />
// image256[(n-256*4)+i]=255;<br />
// image256[(n-256*5)+i]=255;<br />
// image256[(n-256*6)+i]=255;<br />
<br />
store256[n+i] = 255;<br />
store256[(n-256)+i] = 255;<br />
// store256[(n-256*2)+i] = 255;<br />
// store256[(n-256*3)+i] = 255;<br />
// store256[(n-256*4)+i] = 255;<br />
// store256[(n-256*5)+i] = 255;<br />
// store256[(n-256*6)+i] = 255;<br />
}<br />
}<br />
<br />
// pen for image size 512 by 512<br />
if (no_of_rows == 512)<br />
{<br />
er_point = point;<br />
<br />
cur_pos_x = er_point.x - posx512; // Compute the current eraser point position<br />
cur_pos_y = er_point.y - posy512;<br />
n = (512-(cur_pos_y))*512 + cur_pos_x; // Translate it to the image pixel n <br />
<br />
for (int i=0; i<10; i++) <br />
{<br />
image512[n+i] = 255; // Delete for 2 pixels horizontal<br />
image512[(n-512)+i] =255; // Delete 2nd rows each time<br />
image512[(n-512*2)+i]=255; // Delete 3rd row also<br />
image512[(n-512*3)+i]=255;<br />
image512[(n-512*4)+i]=255;<br />
image512[(n-512*5)+i]=255;<br />
image512[(n-512*6)+i]=255;<br />
image512[(n-512*7)+i]=255;<br />
image512[(n-512*8)+i]=255;<br />
image512[(n-512*9)+i]=255;<br />
<br />
<br />
store512[n+i] = 255;<br />
store512[(n-512)+i] = 255;<br />
store512[(n-512*2)+i] = 255;<br />
store512[(n-512*3)+i] = 255;<br />
store512[(n-512*4)+i] = 255;<br />
store512[(n-512*5)+i] = 255;<br />
store512[(n-512*6)+i] = 255;<br />
store512[(n-512*7)+i] = 255;<br />
store512[(n-512*8)+i] = 255;<br />
store512[(n-512*9)+i] = 255;<br />
<br />
}<br />
}<br />
<br />
<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
<br />
Draw();<br />
}<br />
}<br />
<br />
if (zoom == true) // for zoom only<br />
{<br />
//if (leftbut == true)<br />
{<br />
<br />
// do if, if image size is 256 by 256<br />
if (no_of_rows == 256) <br />
{<br />
<br />
<br />
er_point = point;<br />
<br />
cur_pos_x = er_point.x - posx256; // Compute the current mouse point position<br />
cur_pos_y = er_point.y - posy256;<br />
<br />
Draw_Zoom(cur_pos_x, cur_pos_y);<br />
<br />
}<br />
<br />
<br />
// do if, if image size is 512 by 512<br />
if (no_of_rows == 512) <br />
{<br />
<br />
<br />
er_point = point;<br />
<br />
cur_pos_x = er_point.x - posx512; // Compute the current mouse point position<br />
cur_pos_y = er_point.y - posy512;<br />
<br />
Draw_Zoom(cur_pos_x, cur_pos_y);<br />
<br />
<br />
}<br />
<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
<br />
Draw();<br />
<br />
CClientDC zoomDC(this);<br />
zoomDC.SetROP2(R2_NOTXORPEN);<br />
// draw the lines at the exact mouse position<br />
DrawZoomBox(&zoomDC, cur_pos_x, cur_pos_y);<br />
//ClientDC.Rectangle((point.x + 35), (point.y + 35), (point.x - 35), (point.y - 35));<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
if (m_Dragging && m_PointOrigin!=point ) {<br />
<br />
CClientDC ClientDC (this);<br />
mouse2_x = point.x;<br />
mouse2_y = point.y; <br />
<br />
ClientDC.SetROP2(R2_NOTXORPEN); //R2_NOTXORPEN Pixel is the inverse of the R2_XORPEN color. <br />
<br />
if (MotionFix) DrawBox(&ClientDC,m_PointOrigin,m_PointOld);<br />
MotionFix++;<br />
<br />
DrawBox(&ClientDC,m_PointOrigin,point);<br />
}<br />
<br />
m_PointOld = point;<br />
<br />
<br />
//-------------New Coding----------------------//<br />
<br />
if (MDrag && m_PO!=point) { //For dragging onto a point by using the mouse<br />
<br />
Rectn= true;<br />
CClientDC FDC (this);<br />
m2_x = point.x;<br />
m2_y = point.y; <br />
<br />
FDC.SetROP2(R2_NOTXORPEN); //highlights the image// <br />
<br />
if (Motion) DrawRectn(&FDC, m_PO, m_OldPO); //happens when Motion is not 0.<br />
Motion++;<br />
<br />
<br />
<br />
DrawRectn(&FDC,m_PO,point);<br />
<br />
<br />
}<br />
<br />
m_OldPO = point;<br />
<br />
//---------------------------------------------//<br />
<br />
<br />
<br />
<br />
CView::onmousemove(nFlags, point);<br />
}<br />
<br />
<br />
void CMediVisionView::DrawZoomBox(CDC *pdc, int mouse_x, int mouse_y)<br />
{<br />
int half_box_length;<br />
<br />
half_box_length = (ZOOM_BOX / 2);<br />
<br />
if (no_of_rows == 512)<br />
{<br />
// if mouse pointer is within range of image<br />
if (((mouse_x-half_box_length) > 0) && ((mouse_x+half_box_length) < no_of_rows) && ((mouse_y-half_box_length) > 0) && ((mouse_y+half_box_length) < no_of_rows))<br />
{<br />
<br />
CPoint top_left;<br />
CPoint bottom_right;<br />
<br />
top_left.x = mouse_x-(half_box_length)+10;<br />
top_left.y = mouse_y-(half_box_length)+10;<br />
bottom_right.x = mouse_x+(half_box_length)+10;<br />
bottom_right.y = mouse_y+(half_box_length)+10;<br />
<br />
pdc->MoveTo(top_left); // start at top left corner<br />
pdc->LineTo(top_left.x+ZOOM_BOX, top_left.y); // draw line to the right<br />
pdc->LineTo(bottom_right); // then draw line downwards to bottom right corner<br />
<br />
pdc->MoveTo(bottom_right); // now start from bottom right corner<br />
pdc->LineTo(bottom_right.x-ZOOM_BOX, bottom_right.y); // draw line to the left<br />
pdc->LineTo(top_left); // then draw line upwards to top left corner<br />
<br />
if (grid == true)<br />
{<br />
<br />
}<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
void CMediVisionView::Draw_Zoom(int mx, int my)<br />
{<br />
<br />
// to zoom image when zoom is activated and mouse move over image<br />
int ref=0, r=0, c=0, n=0, m=0;<br />
<br />
int row=0, col=0;<br />
//int p, q;<br />
//int cx_position[6], cy_position[6]; <br />
unsigned int data=0;<br />
<br />
<br />
int zoom_rows = ZOOM_BOX;<br />
int zoom_cols = ZOOM_BOX;<br />
<br />
// zoom for image size 256 by 256<br />
if(n_rows==256)<br />
{<br />
// StretchBlt(hdc, posxZOOM,posyZOOM, zoom_rows*8, zoom_cols*8, hdc, ((mx-(ZOOM_BOX/2))), ((my-(ZOOM_BOX/2))), (zoom_rows+(ZOOM_BOX/2)), (zoom_cols+(ZOOM_BOX/2)), SRCCOPY); <br />
StretchBlt(hdc, posxZOOM,posyZOOM, zoom_rows*magnification, zoom_cols*magnification, hdc, ((mx-(ZOOM_BOX/2))+10), ((my-(ZOOM_BOX/2))+10), zoom_rows, zoom_cols, SRCCOPY); // +10 to offset 10 pix by 10 pix<br />
<br />
} <br />
<br />
<br />
// zoom for image size 512 by 512<br />
if(n_rows==512)<br />
{ <br />
// StretchBlt(hdc, posxZOOM,posyZOOM, zoom_rows*8, zoom_cols*8, hdc, ((mx-(ZOOM_BOX/2))), ((my-(ZOOM_BOX/2))), (zoom_rows+(ZOOM_BOX/2)), (zoom_cols+(ZOOM_BOX/2)), SRCCOPY); <br />
StretchBlt(hdc, posxZOOM,posyZOOM, zoom_rows*magnification, zoom_cols*magnification, hdc, ((mx-(ZOOM_BOX/2))+10), ((my-(ZOOM_BOX/2))+10), zoom_rows, zoom_cols, SRCCOPY); // +10 to offset 10 pix by 10 pix<br />
}<br />
<br />
}<br />
<br />
void CMediVisionView::OnZoom2x() <br />
{<br />
// TODO: Add your command handler code here<br />
<br />
image32 = new int [ZOOM_BOX * ZOOM_BOX];<br />
<br />
magnification = 2;<br />
<br />
if (!zoom) // toggle zoom on/off<br />
zoom = true; <br />
else<br />
zoom = false;<br />
<br />
<br />
}<br />
<br />
void CMediVisionView::OnZoom4x() <br />
{<br />
// TODO: Add your command handler code here<br />
<br />
image32 = new int [ZOOM_BOX * ZOOM_BOX];<br />
<br />
magnification = 4;<br />
<br />
if (!zoom) // toggle zoom on/off<br />
zoom = true; <br />
else<br />
zoom = false;<br />
<br />
<br />
}<br />
<br />
void CMediVisionView::OnSegmentationRegiongrowing() <br />
{<br />
// TODO: Add your command handler code here<br />
box = true;<br />
}<br />
<br />
BOOL CMediVisionView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) <br />
{<br />
// TODO: Add your message handler code here and/or call default<br />
<br />
if(box) {<br />
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));<br />
return TRUE;<br />
}<br />
<br />
//-----New coding------//<br />
if(Rectn) { <br />
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS)); //Mouse cursor changes to Cross cursor//<br />
return TRUE;<br />
<br />
}//---End of new coding-----//<br />
<br />
<br />
if(zoom) {<br />
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));<br />
return TRUE;<br />
}<br />
if(eraser) { //eraser is activated<br />
CWinApp* pApp=AfxGetApp(); //load Square cursor for erasing of image<br />
HICON hIconBang =pApp->LoadCursor(IDC_CURSOR1);<br />
SetCursor(hIconBang);<br />
return TRUE;<br />
<br />
}<br />
if(insert) { //insert is activated<br />
CWinApp* pApp=AfxGetApp(); //load Square cursor for erasing of image<br />
HICON hIconBang =pApp->LoadCursor(IDC_CURSOR2);<br />
SetCursor(hIconBang);<br />
return TRUE;<br />
<br />
}<br />
<br />
<br />
<br />
return CView::OnSetCursor(pWnd, nHitTest, message);<br />
}<br />
<br />
void CMediVisionView::Segment_Region()<br />
{<br />
int ref, r, c, n;<br />
<br />
int segment_length = abs(mouse2_x - mouse1_x); // length of the box for segmentation;<br />
int segment_height = abs(mouse2_y - mouse1_y); // height of the box for segmentation<br />
<br />
<br />
region = new int*[segment_height]; <br />
for (int i=0; i region[i] = new int[segment_length]; // create a 2 dimension array to store the selected part<br />
}<br />
<br />
<br />
// Compute the start point with reference to the image left hand corner;<br />
<br />
if (no_of_rows == 256 && !multiple_open) {<br />
box_x = mouse1_x - posx256; // 10 is because the StretchDIbits command has <br />
box_y = mouse1_y - posy256; // set the corner of image at (5, 5)<br />
<br />
n = (256-(box_y+1))*256 + box_x; // +1 because it should not include the current row<br />
ref = 0; // and 512-(...) because in screen bottom left hand corner is (0,0)<br />
<br />
for (r=0; r for (c=0; c region[r][c] = image256[n];<br />
<br />
n++;<br />
ref++; <br />
if (ref == segment_length) { // To compute the n wrt to row(r) and col(c)<br />
n = ((256-(box_y+1))-r)*256 + box_x;<br />
ref = 0;<br />
}<br />
} <br />
}<br />
<br />
// Performing the segmentation in this region that was selected by the box <br />
<br />
ref_selected_x = clk_mouse_x - posx256; // compute the reference point position<br />
ref_selected_y = clk_mouse_y - posy256;<br />
<br />
n = (256-(ref_selected_y))*256 + ref_selected_x;<br />
ref_intensity = image256[n];<br />
image256[n] = ref_intensity + 100; // Make the reference point slightly whiter only<br />
<br />
for (r=0; r for (c=0; c if ((region[r][c] <= ref_intensity+10) && (region[r][c] >= ref_intensity-10)) {<br />
n = ((256-(box_y+1))-r)*256 + box_x+c;<br />
image256[n] = 255;<br />
}<br />
}<br />
}<br />
}<br />
if (no_of_rows == 512) {<br />
box_x = mouse1_x - posx512; // 5 is because the StretchDIbits command has <br />
box_y = mouse1_y - posy512; // set the corner of image at (5, 5)<br />
<br />
n = (512-(box_y+1))*512 + box_x; // +1 because it should not include the current row<br />
ref = 0; // and 512-(...) because in screen bottom left hand corner is (0,0)<br />
<br />
for (r=0; r for (c=0; c region[r][c] = image512[n];<br />
<br />
n++;<br />
ref++; <br />
if (ref == segment_length) { // To compute the n wrt to row(r) and col(c)<br />
n = ((512-(box_y+1))-r)*512 + box_x;<br />
ref = 0;<br />
}<br />
} <br />
}<br />
<br />
// Performing the segmentation in this region that was selected by the box <br />
<br />
ref_selected_x = clk_mouse_x - posx512; // compute the reference point position<br />
ref_selected_y = clk_mouse_y - posy512;<br />
<br />
n = (512-(ref_selected_y))*512 + ref_selected_x;<br />
ref_intensity = image512[n];<br />
image512[n] = ref_intensity + 100; // Make the reference point slightly whiter only<br />
<br />
for (r=0; r for (c=0; c if ((region[r][c] <= ref_intensity+10) && (region[r][c] >= ref_intensity-10)) {<br />
n = ((512-(box_y+1))-r)*512 + box_x+c;<br />
image512[n] = 255;<br />
}<br />
}<br />
}<br />
}<br />
Draw();<br />
return;<br />
<br />
delete [] region;<br />
}<br />
<br />
void CMediVisionView::OnFileMultipleopen() <br />
{<br />
// TODO: Add your command handler code here<br />
multiple_open = true;<br />
OpenFile();<br />
}<br />
<br />
void CMediVisionView::OpenFile()<br />
{<br />
static char BASED_CODE szFilter[] = "DICOM (*.dcm)|*.dcm|Bitmap (*.bmp)| *.bmp|";<br />
<br />
CFileDialog dlg(TRUE, NULL, NULL, NULL, szFilter);<br />
if (dlg.DoModal() == IDOK) {<br />
m_File1=dlg.GetFileName();<br />
file = m_File1;<br />
<br />
}<br />
<br />
if ((fp = fopen(m_File1, "rb")) == NULL) {<br />
noFile = true;<br />
}<br />
else {<br />
<br />
noFile = false;<br />
if (multiple_open) image_no++;<br />
}<br />
<br />
Flag3D = false;<br />
ReadFile();<br />
<br />
Invalidate(); // Refresh the Window<br />
<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
Draw();<br />
<br />
}<br />
<br />
void CMediVisionView::OnRToolbar3DIntensity() <br />
{<br />
// TODO: Add your command handler code here<br />
<br />
On3dMaximumintensity();<br />
}<br />
<br />
void CMediVisionView::OnRToolbarMultipleopen() <br />
{<br />
// TODO: Add your command handler code here<br />
OnFileMultipleopen();<br />
}<br />
<br />
<br />
void CMediVisionView::OnRToolbar2Region() <br />
{<br />
// TODO: Add your command handler code here<br />
OnSegmentationRegiongrowing();<br />
}<br />
<br />
void CMediVisionView::On3dVolumerendering() <br />
{<br />
// TODO: Add your command handler code here<br />
int s, n;<br />
int p=0, q=0;<br />
int iGm, Composite;<br />
float Grad_Mag, Ambient, Mag, Diffuse, Light_Mag, Luminance, Alpha, at, la, lum;<br />
float Intensity;<br />
float Light_x = 128+2.5;<br />
float Light_y = 128+2.5;<br />
float Light_z = 1+3.5;<br />
<br />
Light_Mag = (float)sqrt(Light_x*Light_x + Light_y*Light_y + Light_z*Light_z);<br />
Ambient = 0.4f;<br />
Diffuse = 0.6f;<br />
<br />
SetClassificationTable();<br />
<br />
if (no_of_rows==256) {<br />
<br />
//----------------------- Compute the Gradient -------------------------------------------<br />
n = 0;<br />
for (p=0; p for (q=0; q lum = 0;<br />
la = 0;<br />
for (s=1; s if (dcmPixel[s][p*256+q] > 0) {<br />
Grad_x = dcmPixel[s][p*256+(q-1)] - dcmPixel[s][p*256+(q+1)]; <br />
Grad_y = dcmPixel[s][(p-1)*256+q] - dcmPixel[s][(p+1)*256+q];<br />
Grad_z = dcmPixel[s-1][n] - dcmPixel[s+1][n];<br />
Grad_Mag = (float)sqrt(Grad_x*Grad_x + Grad_y*Grad_y + Grad_z*Grad_z);<br />
//----------------------- Compute classify -----------------------------------------------<br />
iGm = (Grad_Mag/442.0f) * 64.0f;<br />
Composite = (iGm<<8) | (dcmPixel[s][p*256+q]);<br />
Alpha = (float)alphaTable[Composite]/255.0f; <br />
Luminance = (float)luminanceTable[Composite];;<br />
//----------------------- Compute Shading ------------------------------------------------<br />
Mag =(Grad_x/Grad_Mag * Light_x/Light_Mag) + <br />
(Grad_y/Grad_Mag * Light_y/Light_Mag) +<br />
(Grad_z/Grad_Mag * Light_z/Light_Mag);<br />
<br />
if (Mag <0.0) Mag = 0.0;<br />
Intensity = Ambient + (Diffuse*Mag);<br />
Luminance = Luminance * Intensity;<br />
//----------------------- Front to back Alpha --------------------------------------------<br />
if (Alpha>0.0) {<br />
at = Alpha * (1.0f - la);<br />
lum = lum + (Luminance * at);<br />
la = la + at;<br />
if (la > 0.97) break;<br />
} <br />
}<br />
}<br />
n++;<br />
image256[n] = lum; <br />
}<br />
} <br />
}<br />
<br />
else {<br />
// ------------------------------------------------------------------------------------------<br />
n = 0;<br />
for (p=0; p for (q=0; q lum = 0;<br />
la = 0;<br />
for (s=1; s if (dcmPixel[s][p*512+q] > 0) {<br />
Grad_x = dcmPixel[s][p*512+(q-1)] - dcmPixel[s][p*512+(q+1)]; <br />
Grad_y = dcmPixel[s][(p-1)*512+q] - dcmPixel[s][(p+1)*512+q];<br />
Grad_z = dcmPixel[s-1][n] - dcmPixel[s+1][n];<br />
<br />
Grad_Mag = (float)sqrt(Grad_x*Grad_x + Grad_y*Grad_y + Grad_z*Grad_z);<br />
// -------------------------- Compute classify --------------------------------------------<br />
iGm = (Grad_Mag/442.0f) * 64.0f;<br />
Composite = (iGm<<8) | (dcmPixel[s][p*512+q]);<br />
Alpha = (float)alphaTable[Composite]/255.0f; <br />
Luminance = (float)luminanceTable[Composite]; <br />
// -------------------------- Compute Shading ---------------------------------------------<br />
Mag =(Grad_x/Grad_Mag * Light_x/Light_Mag) + <br />
(Grad_y/Grad_Mag * Light_y/Light_Mag) +<br />
(Grad_z/Grad_Mag * Light_z/Light_Mag);<br />
<br />
if (Mag <0.0) Mag = 0.0;<br />
Intensity = Ambient + (Diffuse*Mag);<br />
Luminance = Luminance * Intensity;<br />
// -------------------------- Front to back Alpha -----------------------------------------<br />
if (Alpha>0.0) {<br />
at = Alpha * (1.0f - la);<br />
lum = lum + (Luminance * at);<br />
la = la + at;<br />
if (la > 0.97) break;<br />
} <br />
}<br />
}<br />
n++;<br />
image512[n] = lum; <br />
}<br />
} <br />
}<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
Draw();<br />
}<br />
<br />
void SetClassificationTable() {<br />
float alpha;<br />
float levWidth, levThreshold;<br />
int index, magnitude, intensity, ind;<br />
<br />
levThreshold = (float)128.0;<br />
levWidth = (float) 2.0;<br />
<br />
for (index=0; index<4; index++) {<br />
for (magnitude=0; magnitude < 64; magnitude ++) {<br />
for (intensity=0; intensity < 256; intensity++) {<br />
ind = intensity + (magnitude<<8) + (index<<14);<br />
<br />
if ((intensity >=levThreshold) && (intensity < (levThreshold + levWidth)))<br />
alpha = ((float)intensity - levThreshold)/levWidth;<br />
else if (intensity < levThreshold)<br />
alpha = (float)0.0;<br />
else<br />
alpha = (float)1.0;<br />
<br />
if (alpha>0.0) {<br />
alphaTable[ind] = (255.0*alpha);<br />
}<br />
else<br />
alphaTable[ind] = 0;<br />
<br />
luminanceTable[ind] = 255;<br />
}<br />
}<br />
}<br />
}<br />
<br />
void CMediVisionView::OnToolsEraser() <br />
{<br />
// TODO: Add your command handler code here <br />
if (!eraser) // Toggle<br />
eraser = true;<br />
else<br />
eraser = false;<br />
}<br />
<br />
void CMediVisionView::OnToolsBoolean() <br />
{<br />
// TODO: Add your command handler code here<br />
FILE* fb; // Pointer for bitmap file<br />
short c1, c2;<br />
int i, j, c;<br />
int BitmapWidth, BitmapHeight, intval, psize;<br />
short shortval;<br />
<br />
if ((fb=fopen("d:\\bmestudent\\Medical Visualization 32\\Chee-Boon_LEO-MedicalVisualization31\\512 bitmap\\bitmap512res2(3)-1.bmp", "rb")) == NULL) {<br />
AfxMessageBox("Cannot Open Bitmap File! ");<br />
fclose(fb);<br />
exit(1);<br />
}<br />
<br />
/*-------------- Read Bitmap File Info ------------------------------------------------<br />
This size is 14 bytes<br />
16 bits : Magic Number "BM"<br />
32 bits : Size of file in 32-bit Integer<br />
16 bits : Reserved 1 (always 0)<br />
16 bits : Reserved 2 (always 0)<br />
32 bits : Starting position of image data, in bytes<br />
---------------------------------------------------------------------------------------*/<br />
<br />
c1 = fgetc(fb);<br />
c2 = fgetc(fb);<br />
if (c1 != 'B' || c2 != 'M') {<br />
AfxMessageBox("Bitmap File Error 1! "); <br />
return; <br />
}<br />
<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
fread(&shortval, sizeof(unsigned short), 1, fb);<br />
fread(&shortval, sizeof(unsigned short), 1, fb);<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
<br />
/* --------------Read Bitmap Header ----------------------------------------------------<br />
This size is 40 bytes<br />
32 bits : (unsigned) size of this header<br />
32 bits : Width<br />
32 bits : Height<br />
<br />
16 bits : Planes (no of colour planes, always 1)<br />
16 bits : BitsPerPixel (1 to 24. 1, 4, 8 and 24 are legal.<br />
<br />
32 bits : (unsigned) compression (1, 8 bit RLE; 2, 4 bit RLE; 3 bitfield)<br />
32 bits : SizeofBitmap in bytes (0 if uncompressed)<br />
32 bits : H-Resolution (Pixels per meter, can be 0)<br />
32 bits : V-Resolution (Pixels per meter, can be 0)<br />
32 bits : (unsigned) ColorsUsed (No. of colours in palette, can be 0)<br />
32 bits : ColorImportant (Minimum number of important colors, can be 0)<br />
----------------------------------------------------------------------------------------*/<br />
<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
fread(&BitmapWidth, sizeof(unsigned int), 1, fb);<br />
fread(&BitmapHeight, sizeof(unsigned int), 1, fb);<br />
<br />
fread(&shortval, sizeof(unsigned short), 1, fb);<br />
fread(&shortval, sizeof(unsigned short), 1, fb);<br />
<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
fread(&psize, sizeof(unsigned int), 1, fb);<br />
fread(&intval, sizeof(unsigned int), 1, fb);<br />
<br />
/* ---------------- Read the Color Palette --------------------------------------------*/<br />
<br />
for (i=0; i for (j=0; j<4; j++) {<br />
c=fgetc(fb);<br />
if (c== EOF) return;<br />
}<br />
}<br />
<br />
/* ---------------- Read Bimap Pixel Data ---------------------------------------------*/<br />
int n = 0;<br />
<br />
Bitmap_r = new int[BitmapWidth*BitmapHeight];<br />
Bitmap_g = new int[BitmapWidth*BitmapHeight];<br />
Bitmap_b = new int[BitmapWidth*BitmapHeight];<br />
<br />
for (j=0; j for (i=0; i Bitmap_r[n] = fgetc(fb);<br />
Bitmap_g[n] = fgetc(fb);<br />
Bitmap_b[n] = fgetc(fb);<br />
n++;<br />
}<br />
}<br />
<br />
n=0;<br />
for (j=0; j for (i=0; i if (Bitmap_r[n] <10) {<br />
image512[n] = 0;<br />
store512[n] = 0; <br />
}<br />
// else {<br />
// image512[n] = 255;<br />
// store512[n] = 255; <br />
// }<br />
n++;<br />
}<br />
}<br />
// BmpDraw();<br />
<br />
pDC = GetDC();<br />
hdc=pDC->GetSafeHdc();<br />
Draw();<br />
<br />
fclose(fb);<br />
<br />
delete [] Bitmap_r;<br />
delete [] Bitmap_g;<br />
delete [] Bitmap_b;<br />
<br />
return;<br />
}<br />
<br />
void CMediVisionView::BmpDraw()<br />
{<br />
int row, col, data;<br />
int n=0;<br />
<br />
BITMAPINFOHEADER infoHeader;<br />
infoHeader.biSize = sizeof(BITMAPINFOHEADER);<br />
infoHeader.biWidth = 512;<br />
infoHeader.biHeight = 512;<br />
infoHeader.biPlanes=1;<br />
infoHeader.biBitCount= 24;<br />
infoHeader.biCompression=0;<br />
infoHeader.biSizeImage=0;<br />
infoHeader.biXPelsPerMeter=0;<br />
infoHeader.biYPelsPerMeter=0;<br />
infoHeader.biClrUsed=0;<br />
infoHeader.biClrImportant=0;<br />
<br />
<br />
for(int p=0;p<512;p++) {<br />
for (int q=0;q<512;q++) {<br />
data=Bitmap_r[n];<br />
if(data <= 0) {<br />
argbPixels[p][q] = (unsigned int)(0 | 0 | 0 | 0);<br />
<br />
}<br />
else {<br />
argbPixels[p][q] = (unsigned int)(data << 24 | data <<16 | data<<8 | data);<br />
}<br />
n++; <br />
}<br />
}<br />
<br />
argbPixelsPtr = (unsigned char *) argbPixels;<br />
rgbPixelsPtr = (unsigned char *) rgbPixels;<br />
<br />
for (row=0; row<512; row++) {<br />
for(col=0; col<512; col++) {<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
*rgbPixelsPtr++ = *argbPixelsPtr++;<br />
argbPixelsPtr++;<br />
} <br />
}<br />
<br />
StretchDIBits(hdc, 10, 10, 512, 512, 0, 0, 512, 512, rgbPixels,(BITMAPINFO*) &infoHeader, 0, SRCCOPY); <br />
<br />
return;<br />
} <br />
<br />
<br />
void CMediVisionView::OnToolsMaximation() <br />
{<br />
// TODO: Add your command handler code here<br />
int i, j, n;<br />
n=0;<br />
if (no_of_rows == 256) {<br />
for (j=0; j for (i=0; i if (image256[n]>150) {<br />
image256[n]=255;<br />
store256[n]=255;<br />
}<br />
n++;<br />
}<br />
}<br />
}<br />
else if (no_of_rows == 512) {<br />
for (j=0; j for (i=0; i if (image512[n]>150) {<br />
image512[n]=255;<br />
store512[n]=255;<br />
}<br />
n++;<br />
}<br />
}<br />
}<br />
Draw();<br />
}<br />
<br />
void CMediVisionView::OnEraser() <br />
{<br />
// TODO: Add your command handler code here<br />
OnToolsEraser();<br />
}<br />
<br />
<br />
<br />
void CMediVisionView::OnToolsPen() <br />
{<br />
// TODO: Add your command handler code here<br />
if (!insert) // Toggle<br />
insert = true;<br />
else<br />
insert = false;<br />
}<br />
<br />
void CMediVisionView::OnPen() <br />
{<br />
// TODO: Add your command handler code here<br />
OnToolsPen();<br />
}<br />
<br />
void CMediVisionView::OnEditPatientData() <br />
{<br />
// CEdit_Patient_Data EditDlg;<br />
// EditDlg.DoModal();<br />
// TODO: Add your command handler code here<br />
EditDlg = new CEdit_Patient_Data(this);<br />
EditDlg -> Create(CEdit_Patient_Data::IDD,this);<br />
EditDlg -> ShowWindow(SW_SHOW);<br />
EditDlg -> Edit_Patient();<br />
// //EditDlg -> OnOK();<br />
<br />
<br />
<br />
<br />
<br />
}<br />
<br />
void CMediVisionView::OnMorpholofical() <br />
{<br />
// TODO: Add your command handler code here<br />
int n;<br />
int rows = 0, cols = 0;<br />
<br />
if (no_of_rows == 512){<br />
for(rows=0; rows for(cols=0;cols<br />
n = ((512-rows-1)*512)+(cols);<br />
if ((image512[n]>100)||(image512[(n+1)]>100)||(image512[(n-512)]>100)||(image512[((n-512)+1)]>100)){<br />
<br />
image512[n] =255;<br />
image512[(n+1)] =255;<br />
image512[(n-512)] =255;<br />
image512[(n-512)+1] =255;<br />
<br />
store512[n] =255;<br />
store512[(n+1)] =255;<br />
store512[(n-512)] =255;<br />
store512[(n-512)+1] =255;<br />
<br />
<br />
}<br />
}<br />
}<br />
pDC = GetDC();<br />
hdc= pDC->GetSafeHdc();<br />
Draw();<br />
<br />
}<br />
}<br />
<br />
<br />
void CMediVisionView::OnToolsExpansion() <br />
{<br />
cancel1= false;<br />
cancel2= false;<br />
CExpand_Pixel ExpandDlg(this);<br />
ExpandDlg.DoModal();<br />
if(cancel1==false)<br />
{<br />
CRows_Cols RowsColsDlg(this);<br />
RowsColsDlg.DoModal();<br />
if(cancel2== false)<br />
{ <br />
<br />
<br />
<br />
int n,q,i=0;<br />
int rows =0 , cols =0;<br />
int rows512 , cols512 ;<br />
int *temp;<br />
<br />
temp = new int [512*512];<br />
<br />
<br />
if (Expand_Pixel == 2) {<br />
for(rows=rows1; rows for(cols=cols1;cols<br />
<br />
<br />
n = ((512-rows-1)*512)+(cols);<br />
<br />
temp[i] =image512[n];<br />
i++;<br />
}<br />
}<br />
<br />
<br />
i=0;<br />
for(rows512=0; rows512<512;rows512=(rows512+2)){<br />
for(cols512=0;cols512<512;cols512=(cols512+2)){<br />
q = ((512-rows512-1)*512)+(cols512);<br />
<br />
image512[q] =temp[i];<br />
image512[q+1] =temp[i];<br />
image512[q-512] =temp[i];<br />
image512[(q-512)+1] =temp[i]; <br />
<br />
store512[q] =temp[i];<br />
store512[q+1] =temp[i];<br />
store512[q-512] =temp[i];<br />
store512[(q-512)+1] =temp[i];<br />
<br />
i++;<br />
<br />
}<br />
<br />
// }<br />
}<br />
<br />
}<br />
<br />
if(Expand_Pixel == 3) <br />
{<br />
<br />
for(rows=rows1; rows {<br />
for(cols=cols1;cols {<br />
<br />
n = ((512-rows-1)*512)+(cols);<br />
<br />
temp[i] =image512[n];<br />
i++;<br />
}<br />
}<br />
<br />
<br />
i=0;<br />
for(rows512=0; rows512<509;rows512=(rows512+3))<br />
{<br />
for(cols512=0;cols512<509;cols512=(cols512+3))<br />
{<br />
<br />
q = ((512-rows512-1)*512)+(cols512);<br />
<br />
<br />
image512[q] =temp[i];<br />
image512[q+1] =temp[i];<br />
image512[q+2] =temp[i];<br />
image512[q-512] =temp[i];<br />
image512[(q-512)+1] =temp[i];<br />
image512[(q-512)+2] =temp[i];<br />
image512[(q-512)-512] =temp[i];<br />
image512[(q-1024)+1] =temp[i];<br />
image512[(q-1024)+2] =temp[i];<br />
<br />
store512[q] =temp[i];<br />
store512[q+1] =temp[i];<br />
store512[q+2] =temp[i];<br />
store512[q-512] =temp[i];<br />
store512[(q-512)+1] =temp[i];<br />
store512[(q-512)+2] =temp[i];<br />
store512[q-1024] =temp[i];<br />
store512[(q-1024)+1] =temp[i];<br />
store512[(q-1024)+2] =temp[i];<br />
<br />
<br />
i++;<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
if(Expand_Pixel == 4 )<br />
{<br />
for(rows=rows1; rows {<br />
for(cols=cols1;cols {<br />
<br />
n = ((512-rows-1)*512)+(cols);<br />
temp[i] =image512[n];<br />
i++;<br />
}<br />
}<br />
<br />
<br />
i=0;<br />
for(rows512=0; rows512<508;rows512=(rows512+4))<br />
{<br />
for(cols512=0;cols512<508;cols512=(cols512+4))<br />
{<br />
q = ((512-rows512-1)*512)+(cols512);<br />
<br />
image512[q] =temp[i];<br />
image512[q+1] =temp[i];<br />
image512[q+2] =temp[i];<br />
image512[(q+3)] =temp[i];<br />
image512[q-512] =temp[i];<br />
image512[(q-512)+1] =temp[i];<br />
image512[(q-512)+2] =temp[i];<br />
image512[(q-512)+3] =temp[i];<br />
image512[(q-512)-512] =temp[i];<br />
image512[(q-1024)+1] =temp[i];<br />
image512[(q-1024)+2] =temp[i];<br />
image512[(q-1024)+3] =temp[i];<br />
image512[(q-1536)] =temp[i];<br />
image512[(q-1536)+1] =temp[i];<br />
image512[(q-1536)+2] =temp[i];<br />
image512[(q-1536)+3] =temp[i];<br />
<br />
<br />
<br />
<br />
store512[q] =temp[i];<br />
store512[q+1] =temp[i];<br />
store512[q+2] =temp[i];<br />
store512[q+3] =temp[i];<br />
store512[q-512] =temp[i];<br />
store512[(q-512)+1] =temp[i];<br />
store512[(q-512)+2] =temp[i];<br />
store512[(q-512)+3] =temp[i];<br />
store512[q-1024] =temp[i];<br />
store512[(q-1024)+1] =temp[i];<br />
store512[(q-1024)+2] =temp[i];<br />
store512[(q-1024)+3] =temp[i];<br />
store512[(q-1536)] =temp[i];<br />
store512[(q-1536)+1] =temp[i];<br />
store512[(q-1536)+2] =temp[i];<br />
store512[(q-1536)+3] =temp[i];<br />
<br />
i++;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
<br />
Draw(); <br />
Expand_Pixel = 0;<br />
<br />
}<br />
<br />
//-----------New coding---------------//<br />
void CMediVisionView::OnLineObjects() <br />
{<br />
<br />
Rectn = true;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
void DrawRectn(CDC *pDc , CPoint m_1, CPoint m_2)<br />
{<br />
pDc->MoveTo(m_1);<br />
pDc->LineTo(m_1.x, m_2.y);<br />
<br />
pDc->MoveTo(m_1);<br />
pDc->LineTo(m_2.x, m_1.y);<br />
<br />
pDc->MoveTo(m_2.x,m_1.y);<br />
pDc->LineTo(m_2.x, m_2.y);<br />
<br />
pDc->MoveTo(m_1.x,m_2.y);<br />
pDc->LineTo(m_2.x, m_2.y);<br />
<br />
}<br />
<br />
<br />
<br />
void CMediVisionView::OnRButtonDown(UINT nFlags, CPoint point) <br />
{<br />
// TODO: Add your message handler code here and/or call default<br />
<br />
<br />
<br />
CPoint ptRefer;<br />
ptRefer = point;<br />
<br />
point_x = ptRefer.x;<br />
point_y = ptRefer.y;<br />
int n=0;<br />
<br />
if (minflag == true) {<br />
<br />
point_x1 = point_x - posx512; <br />
point_y1 = point_y - posy512; <br />
n = (512-(point_y1+1))*512 + point_x1; <br />
// image512[n]=255;<br />
mini= image512[n];<br />
maxflag=true;<br />
MessageBox("Pls Right-Click to find Maximum point WITHIN the box.");<br />
}<br />
<br />
<br />
if(minflag==false && maxflag==true){<br />
<br />
point_w1 = point_x - posx512; <br />
point_z1 = point_y - posy512; <br />
n = (512-(point_z1+1))*512 + point_w1;<br />
// image512[n]=255;<br />
maxi= image512[n];<br />
maxflag=false;<br />
}<br />
<br />
minflag = false;<br />
<br />
//--------Image Intensity-------//<br />
if(minflag==false && maxflag==false){<br />
int Column,Row;<br />
<br />
int length, height, refer;<br />
int diff = (maxi - mini);<br />
length= abs(m2_x - m1_x); // length of the rectangular box for segmentation;<br />
height= abs(m2_y - m1_y);<br />
<br />
Rectx = m1_x - posx512;<br />
Recty = m1_y - posy512;<br />
<br />
n = (512-(Recty+1))*512 + Rectx;<br />
<br />
refer=0;<br />
for (Row=0; Row for (Column=0; Column if ((image512[n]>maxi+(int)(0.2*diff)) || (image512[n] image512[n] = 0;<br />
<br />
}<br />
<br />
if(refer == length){<br />
n = ((512-(Recty+1))-Row)*512 + Rectx;<br />
refer = 0; <br />
}<br />
refer++;<br />
n++;<br />
}<br />
}<br />
<br />
<br />
Draw();<br />
}<br />
<br />
//-----------------------//<br />
<br />
<br />
<br />
CView::OnRButtonDown(nFlags, point);<br />
}<br />
<br />
<br />
<br />
<br />
void CMediVisionView::AreaSegmentation()<br />
{<br />
int i, j, n;<br />
n = 0;<br />
<br />
sg_length= abs(m2_x - m1_x); // length of the rectangular box for segmentation;<br />
sg_height = abs(m2_y - m1_y); // height of the rectangular box for segmentation;<br />
<br />
Rectn_x = m1_x - posx512; // 5 is because the StretchDIbits command has <br />
Rectn_y = m1_y - posy512; // set the corner of image at (5, 5)<br />
<br />
int reference;<br />
int row, column;<br />
<br />
<br />
if(no_of_rows == 512 && no_of_cols==512){ //if 512 by 512 pixels<br />
<br />
<br />
num = (512-(Rectn_y+1))*512 + Rectn_x; //calculations for the co-ordinates for the points of the rectangular box <br />
reference = 0;<br />
<br />
n=0; //initialise it to Zero.<br />
for(i=0; i for(j=0; j <br />
store512[n] = 0; //define image to be stored into black background<br />
n++;<br />
} <br />
}<br />
<br />
for (row=0; row for (column=0; column <br />
store512[num]= image512[num]; //stores the image found in image512[num] into store512[num]<br />
<br />
if(reference == sg_length){<br />
num = ((512-(Rectn_y+1))-row)*512 + Rectn_x; //calculations for the co-ordinates for the points of the rectangular box <br />
reference = 0; <br />
<br />
} <br />
num++;<br />
reference++;<br />
}<br />
}<br />
<br />
n=0;<br />
for(i=0; i for(j=0; j image512[n]=0; //define image to be made into black background<br />
n++;<br />
}<br />
}<br />
<br />
n=0;<br />
for(i=0; i for(j=0; j image512[n]=store512[n]; //image being copied & overwritten into image512[n] with new black background image<br />
n++; //So as to replace the previous one so that the image of another can appear<br />
} <br />
}<br />
<br />
}<br />
<br />
// pDC = GetDC();<br />
// hdc= pDC->GetSafeHdc();<br />
// Draw();<br />
<br />
return; <br />
<br />
<br />
}<br />
<br />
//------------End of coding-----------------//<br />

GeneralRe: Visual C++ (MFC) : Using Matrix to set an part of an image to zero Pin
User 58385215-Sep-04 20:23
User 58385215-Sep-04 20:23 
GeneralRe: Visual C++ (MFC) : Using Matrix to set an part of an image to zero Pin
pohcb_sonic15-Sep-04 21:45
pohcb_sonic15-Sep-04 21:45 
GeneralGet Hard Drive Serial Number in VC++ Pin
gokings15-Sep-04 20:13
gokings15-Sep-04 20:13 
GeneralRe: Get Hard Drive Serial Number in VC++ Pin
Arsalan Malik15-Sep-04 21:00
Arsalan Malik15-Sep-04 21:00 
GeneralRe: Get Hard Drive Serial Number in VC++ Pin
gokings18-Sep-04 2:45
gokings18-Sep-04 2:45 
GeneralRe: Get Hard Drive Serial Number in VC++ Pin
wb15-Sep-04 21:00
wb15-Sep-04 21:00 
GeneralRe: Get Hard Drive Serial Number in VC++ Pin
Arsalan Malik15-Sep-04 21:27
Arsalan Malik15-Sep-04 21:27 
GeneralRe: Get Hard Drive Serial Number in VC++ Pin
gokings18-Sep-04 2:39
gokings18-Sep-04 2:39 
GeneralRe: Get Hard Drive Serial Number in VC++ Pin
Aamir Butt16-Sep-04 2:09
Aamir Butt16-Sep-04 2:09 
GeneralDoes MFC Supports IPv6 Pin
Alpha Siera15-Sep-04 20:13
Alpha Siera15-Sep-04 20:13 
GeneralRe: Does MFC Supports IPv6 Pin
Alexander M.,16-Sep-04 9:53
Alexander M.,16-Sep-04 9:53 
GeneralRe: Does MFC Supports IPv6 Pin
Alpha Siera16-Sep-04 18:34
Alpha Siera16-Sep-04 18:34 
GeneralConnection to COM object Pin
dudic15-Sep-04 19:37
dudic15-Sep-04 19:37 
GeneralRe: Connection to COM object Pin
Antti Keskinen16-Sep-04 0:58
Antti Keskinen16-Sep-04 0:58 
QuestionHow to Remove ActiveX from project VC++6 Pin
Sumit Kapoor15-Sep-04 19:20
Sumit Kapoor15-Sep-04 19:20 
AnswerRe: How to Remove ActiveX from project VC++6 Pin
Hardy_Smith15-Sep-04 21:52
Hardy_Smith15-Sep-04 21:52 
GeneralMany Fancy window style in vc++ Pin
vc-programmer-15-Sep-04 19:16
vc-programmer-15-Sep-04 19:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.