|
You could create an array of pointers if you know the value of n at compile time.
char *strings[50];
Now as you save each string to this array allocate the size.
strings[count] = malloc(sizeof(string) + 1);
strcpy(strings[count], string);
If the value of n is not known at compile time, create a pointer to a pointer.
char **strings;
When you get the value of n, allocate the array.
*strings = malloc(sizeof(char*) * n);
Allocation for each string is the same as above.
Don't forget to increment the count variable after to store every string.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi All,
Can anybody tell me how to use command EXECUTE_OFFLINE_DIAGS and subcommand SMART_SHORT_SELFTEST_OFFLINE.How to get its result.I know its used with IOCTL code SMART_SEND_DRIVE_COMMAND.But I am unable to get the result of SMART_SHORT_SELFTEST_OFFLINE.It would be better if anybody could help me with the help of a source code.
Regards
Abinash
|
|
|
|
|
Hi
how to Drawing lines, shapes on bitmaps ??
Plz give any sample pgm
thanks
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
1 Create a memory DC( CreateCompatibleDC )
2 Select the bitmap to that dc ( memdc.SelectObject )
3 Draw your lines/shapes to that DC.
4 Unselect the bitmap from dc.
Now your original bitmap will be having the drawings...
|
|
|
|
|
Hi naveen
Thanks for your replay .. i tried
HDC pDC=::GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
CImage _image;
_image.Load(_T("//read.tif"));
CRect Recto(20, 20, 20, 20);
int width=_image.GetWidth();
int height=_image.GetHeight();
HDC dcBmp=CreateCompatibleDC(TmpDC);
HGDIOBJ TmpObj2 = SelectObject(dcBmp,(HGDIOBJ)_image);
BitBlt(TmpDC,0,0,width,height,dcBmp,0,0,SRCCOPY);
SelectObject(TmpDC,TmpObj2);
DeleteDC(dcBmp);
but its not showing the rectangles in image ..??
plz reply
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
You could try changing the line
SelectObject(dcBmp,(HGDIOBJ)_image);
with
SelectObject(dcBmp,(HGDIOBJ)(HBITMAP)_image);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
its not working "superman"
its not showing any effect on images till the same image ...
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
Check are return values for errors.
There was probably some error encountered at Load or one of earlier functions called.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
No its not showing any error msg ...
i dont know why ..??
please
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
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~~~~~~~~~~~~~
|
|
|
|