|
you said you want to draw some lines and shapes. But the above code is not doing any of that.
rajugis wrote: HDC dcBmp=CreateCompatibleDC(TmpDC); HGDIOBJ TmpObj2 = SelectObject(dcBmp,(HGDIOBJ)_image); BitBlt(TmpDC,0,0,width,height,dcBmp,0,0,SRCCOPY);
What the above code does is copy the image in dcBmp to TmpDC. The dcBmp has your image, but the target dc TmpDC doesnt have any bitmap selected into it. So basically that BitBlt function does nothing. To have a valid image in the TempDC, you have to select one bitmap to that dc. Check the below code(especially the one in the bold ). The hBmp conatins the final image.
HDC dcBmp=CreateCompatibleDC(pDC);
HBITMAP hBmp = CreateCompatibleBitmap(pDC, 20,20);
HGDIOBJ OldBmp = SelectObject(TmpDC,(HGDIOBJ)hBmp);
HGDIOBJ TmpObj2 = SelectObject(dcBmp,(HGDIOBJ)_image);
BitBlt(TmpDC,0,0,width,height,dcBmp,0,0,SRCCOPY);
SelectObject(dcBmp,TmpObj2);
SelectObject(TmpDC,OldBmp);
|
|
|
|
|
hi Naveen
Still its not drawing rectangles in image ...plz mention where i can correct it ..??
HDC pDC=::GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
CImage _image;
_image.Load(_T("read.tif"));
int width=_image.GetWidth();
int height=_image.GetHeight();
HDC dcBmp=CreateCompatibleDC(pDC);
HBITMAP hBmp = CreateCompatibleBitmap(pDC, 20,20);
HGDIOBJ OldBmp = SelectObject(TmpDC,(HGDIOBJ)hBmp);
BitBlt(TmpDC,0,0,width,height,dcBmp,0,0,SRCCOPY);
SelectObject(TmpDC,OldBmp);
please replay me !!!!!!!1
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
rajugis wrote: Still its not drawing rectangles in image ...plz mention where i can correct it ..??
Where is the code to draw a rectangle?
rajugis wrote: //HGDIOBJ hgdiobj = SelectObject(TmpDC,(HGDIOBJ)_image);
Why did you comment it? Also correct this line as SuperMan mentioned.
HGDIOBJ hgdiobj = SelectObject(TmpDC,(HGDIOBJ)(HBITMAP)_image);
|
|
|
|
|
Sorry to say naveen ..really i dont know the rectangle code..
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
try the below code. If everthing goes fine, it will draw a rectangle on the top left portion of the image;
HDC pDC=::GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
CImage _image;
_image.Load(_T("//read.tif"));
int width=_image.GetWidth();
int height=_image.GetHeight();
HGDIOBJ TmpObj2 = SelectObject(TmpDC,(HGDIOBJ)(HBITMAP)_image);
Rectangle(TmpDC, 0,0, width/2, height/2 );
SelectObject(TmpDC,TmpObj2);
ReleaseDC(pDC);
|
|
|
|
|
ReleaseDC(pDC);
Showing Error message naveen like
error C2664: 'CWnd::ReleaseDC' : cannot convert parameter 1 from 'HDC' to 'CDC *'
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
modify
::ReleaseDC(0, pDC);
|
|
|
|
|
its execute completly with out error but its not creating any rectangle in image... naveen ...
HGDIOBJ TmpObj2 = SelectObject(TmpDC,(HGDIOBJ)(HBITMAP)_image);
Rectangle(TmpDC, 0,0, width/2, height/2 );
SelectObject(TmpDC,TmpObj2);
::ReleaseDC(NULL,pDC);
any need to create the new bitmap for this HGDIOBJ TmpObj2 ..??
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
How did u verify that no rectangle is coming..?
|
|
|
|
|
just i save the image like read.tif ..its not show the rectangle so that??
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
hope you saved the image like the code below
_image.Save( _T("c:\\abcd2.bmp"), Gdiplus::ImageFormatBMP );
|
|
|
|
|
thanks naveen ...i never forget this help
i would like say ..please add my name to your friends list please .
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
rajugis wrote: thanks naveen
Your are welcome.
|
|
|
|
|
hi Naveen ..is that any possible for create the rectangle in Color??
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
Yes. check MSDN[^]. It says, "The current pen outlines the rectangle and the current brush fills it. ".
so create the brush of desired color, select it to the DC and then draw
|
|
|
|
|
one small doubt naveen ....
i want to show only the cutting image portion ..but the output image contains only the except cutting image portion.
??
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
What? I didnt understand..
|
|
|
|
|
u assume ...that
one image file contains 5 buildings ..i want to cut and save only the 5th building ,other buildings are not shown in the image.
but when we are save the image 5th building not shown other four buildings are shown in the image...
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
When I'm working with DC's and Bitmaps, and BitBlts, I like to use the following utility from PJ Arends.
Image Viewer Utility[^]
It lets you debug your code, and see the results of image changes like a variable in a watch window.
Very handy, and a shame PJ isn't around CP anymore. (OK, hardly ever)
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
The following code can run correct in VC6.0,but in VC2005 it can not show the text.
Who can tell me why.
//m_pResult is a CEdit pointer
if(!m_pResult->IsWindowVisible())
{
CRect rect;
this->GetClientRect(rect);
m_pResult->MoveWindow(rect);
m_pResult->ShowWindow(SW_SHOW);
m_pResult->SetWindowTextA("aaaa\r\nbbbbb");
}
else
m_pResult->ShowWindow(SW_HIDE);
be my girl , OK?
|
|
|
|
|
liu3p wrote: m_pResult->SetWindowTextA("aaaa\r\nbbbbb");
May be the project is unicode. Use SetWindowText instead of SetWindowTextA
m_pResult->SetWindowText( _T("aaaa\r\nbbbbb"));
|
|
|
|
|
That is correct.
In VC 6.0 all projects are by default non-unicode.
In VS2005 all projects are by default unicode.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Done.Thank you.
be my girl , OK?
|
|
|
|
|
#include<stdio.h>
#define abs(x) ((x<0)?(-(x)):(x))
#define epsilon .000000000001
#define size 5
double multiply(a,m,product)
double a[size][size],product [size][size];
int *m;
{
int test=0;
int count,i,j,k,l;
double olda[size][size],diff;
for(i=0;i<*m;i++)
for(j=0;j(* m;j++)
olda[i][j]=a[i][j];
for(count=1;count<=1000;count++)
{
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
product[i][j]=0;
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
for(k=0;k<*m;k++)
product[i][j]=product[i][j]+a[i][k]*olda[k][j];
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
{
diff=abs(product[i][j]-olda[i][j]);
if(diff>epsilon)
{
test=1;
for(k=0;k<*m;k++)
for(l=0;l<*m;l++)
olda[k][l]=product[k][l];
}
break;
if(test<1)
{
printf("\nThe numberof iterations is:");
printf("\n");
printf("\n %d",count);
break;
}
test=0;
}
return(0);
}
main()
{
static double a[size][size]={{0.1,1.0,0.0,0.0,0.0},
{0.0,0.0,0.3,0.7,0.0},
{0.0,0.0,0.0,0.2,0.8},
{0.0,0.0,0.1,0.0,0.9},
{1.0,0.0,0.0,0.0,0.0}};
double product[size][size],pi[size],diff;
int test;
int m=size;
int i j;
multiply(a,&m,product);
printf("\n");
printf((" \nThe product is:");
printf("\n");
for(i=0;i<m;i<m;i++)
{
printf("\n");
for(j=0;j<m;j++)
printf(" %15.12f", product[i][j]);
}
printf("\n");
printf("n");
return(0);
}
I got the following error messages when I tried to compile it.
Error 1 error C2065: 'a' : undeclared identifier
Error 2 error C2065: 'm' : undeclared identifier
Error 3 error C2065: 'product' : undeclared identifier
Error 4 error C2448: 'multiply' : function-style initializer appears to be a function definition
Error 5 fatal error C1004: unexpected end-of-file found
Please help me I have been trying to figure out how to fix it.
Thanks
|
|
|
|
|
line #5 needs a semi-colon at the end.
|
|
|
|
|