|
what kind of "buffer" ?
to display anything in Windows, you've got to convert it to a DIB or HBITMAP first.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
I get an image from a frame grabber...
Thus the image comes from a buffer in the SDRam memory. I think it must exist an Object which encapsulate un pointer which pointe to this buffer...
I think... No?
Hello World!!!
from Raphaël
|
|
|
|
|
do you have any documentation?
most devices will return a DIB (HDIB, LPDIB, LPBITMAPINFO, etc) or an HBITMAP.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
For the moment I use some code and that works... but I don't find that very clean...
BITMAPINFO* m_pInfo; // is a member of the view
void CArchitectureView::SetBitmapInfoHeader()
{
unsigned short max_shade = 256;
m_pInfo = (BITMAPINFO *) malloc (sizeof(BITMAPINFOHEADER) + max_shade * sizeof(RGBQUAD));
m_pInfo->bmiHeader.biBitCount = 8;
m_pInfo->bmiHeader.biClrUsed = max_shade;
m_pInfo->bmiHeader.biSize= 40;
m_pInfo->bmiHeader.biPlanes = 1;
m_pInfo->bmiHeader.biCompression = BI_RGB;
m_pInfo->bmiHeader.biSizeImage = 0;
m_pInfo->bmiHeader.biXPelsPerMeter = m_pInfo->bmiHeader.biYPelsPerMeter = 0;
m_pInfo->bmiHeader.biClrImportant = 0;
m_pInfo->bmiHeader.biWidth = 0;
m_pInfo->bmiHeader.biHeight = 0;
for(int i = 0; i < (int)m_pInfo->bmiHeader.biClrUsed; i++) {
m_pInfo->bmiColors[i].rgbBlue = m_pInfo->bmiColors[i].rgbGreen = m_pInfo->bmiColors[i].rgbRed = i * (BYTE)(256 / m_pInfo->bmiHeader.biClrUsed);
m_pInfo->bmiColors[i].rgbReserved = 0;
}
}
I use this method during the Initialize of the view...
void CArchitectureView::OnInitialUpdate()
{
CView::OnInitialUpdate();
if(m_pInfo == NULL)
SetBitmapInfoHeader();
}
And the OnDraw() methods... pIm is a pointer to the image
void CArchitectureView::OnDraw(CDC* pDC)
{
CArchitectureDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->ImAff == NULL)
return;
int H = pDoc->MyImList->GetImage(0).GetHeight();
m_pInfo->bmiHeader.biWidth = pDoc->MyImList->GetImage(0).GetWidth();
m_pInfo->bmiHeader.biHeight = -H;
int mode = pDC->SetStretchBltMode(COLORONCOLOR);
void* pIm = (void*)(pDoc->ImAff);
StretchDIBits(pDC->GetSafeHdc(),
0, 0, m_pInfo->bmiHeader.biWidth, H,
0, 0, m_pInfo->bmiHeader.biWidth, H,
pIm, m_pInfo, DIB_RGB_COLORS, SRCCOPY);
pDC->SetStretchBltMode(mode);
}
yeap... It's clean???
Hello World!!!
from Raphaël
|
|
|
|
|
that's really about as clean as you are going to get. image drawing is not simple.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
In my app I have an IPicture and would like to save this as a gif file (I'm aware of licensing restrictions). However I'm unsure of the best way to go around this? I've found lots of info on other image formats but not this one.
Can anybody shed any light on the best way of doing this please.
Thanks
Jas
|
|
|
|
|
I added a ListControl, which is working fine (no Owner data though)
i can put text into it, but weird thing is that i get the text backward.
I.e:
original text:
aaaaaaaaaaaaa
bbbbbbbbbbbbb
ccccccccccccccccc
ListControl text:
cccccccccccccccc
bbbbbbbbbbbb
aaaaaaaaaaaa
this is weird, now the code i put text into the listControl is this (a function i did):
static int VList(char Temp[])
{
if (hList3==NULL) return 1;
LVITEM LvItem;
memset(&LvItem,0,sizeof(LvItem));
//============================
LvItem.mask=LVIF_TEXT;
LvItem.iItem=0;
LvItem.iSubItem=0;
LvItem.pszText=Temp;
SendMessage(hList3,LVM_INSERTITEM,0,(LPARAM)&LvItem);
return 0;
}
it get the text and put it into the ListControl, but backwarded..
now, i saw in a MFC example that in order to make it Virtual ListControl, i need to use the "Owner data" property, but if i check it i get no text in the ListControl,can anyone tell me why and how to fix it ??
thank u all,
Ben
|
|
|
|
|
You get the text backwards because you insert every new peice of text at position 0 (top of the list). So if you add aaaa at 0 and then add bbbbb at 0, it pushes aaaaaaaa to 1 etc..
Add the item to the end by getting the count of items in the list:
LvItem.iItem = control.GetItemCount() ;
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Hallo! I have a problem concerning adding new elements to a CArray with an CArray inside (which is a pointer)
class cl
{
int i;
CArray<int,int> *ptrint;
CString str;
}
CArray <cl,cl> tst;
when I try to Add a new element to tst, first of all I did the following:
cl toinsert;
toinsert.i = 3;
toinsert.str = _T("asdf");
toinsert.ptrint = new CArray<int,int>
toinsert.ptrint.Add(3);
toinsert.ptrint.Add(4); //2 elements insertet in my int-array
tst.Add(toinsert);
well, this works, but actually the memory of the int-array can not be released by
tst.ptrint->SetSize(0);
and with delete it doesn't work too.
Next thougth was that I get memory just for my "toinsert"-thing and .Add will copy the Data - so I deleted the "toinsert"-thing after inserting but then the int-Array vanishes.
after all I tried to do this:
tst.ptrint = new CArray<int,int>;
which has to work normally but it doesn't !!!
Has anybody a good idea how to solve this problem - I'm getting crazy
thanks a lot out there
|
|
|
|
|
CArray is a template, you cannot use it that way.
You have to declare it in a way, when compiler will know type to insert into it, e.g:
CArray <cl, cl&> tst;
|
|
|
|
|
I think you are better off if you use a std::vector of std::vector . I have used them successfully.
Best regards,
Alexandru Savescu
|
|
|
|
|
thanks a lot you guys, i'll try the std:vector asap, for now i have solved my problem by using a struct cl instead of class cl where i have direct access to my pointer and where i can get mem whereever i want.
i know i have made an error above, its a CArray <t,t> a.s.o.
thank you !
|
|
|
|
|
I have an article on using vector here on CP, it's far superior to CArray which was written to fill the gap until vector arrived.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hi
I want to change the text of the of the status bar and the text of tool tips upon the context.
I can add a pane in witch I can write but I don't know how to write in the message pane.
Is anybody knows how to do that?
Thanks in advance
mic
|
|
|
|
|
There are two ways to do what you want:
1. Get the status bar object and call SetPaneText() on it.
2. For the pane ID e.g. ID_MY_PANE, write a CCmdUI handler for it and update the text in that handler
Not sure about the tooltips.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
thank you very much
I try it
mic
|
|
|
|
|
when drag & drop buttons from CToolBarCtrl, default drag icon is a small hand, i need my own icon for special required.
do u know how to change the small hand to my icon?
thx
includeh10
|
|
|
|
|
Hi,
In a dialog based application, I have a bitmap image displayed in a button.
Now i want to select a part of the image (such as, draw a rectangle in the
image), and then i want to enlarge the selected part of the image or save the selected part as another bmp file. Note that: i used 8-bit bmp image.
How should i do?
Thanks in advance!
chen
|
|
|
|
|
You need to use stretchblt to resize it, and read the FAQ to see how to save it.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Yes, you are right. I can enlarge the image with the stretchblt
function. Thanks a lot. But, i also want to resize the size of the
image to fit the size of the dialog. Because the dialog is resizable. Is there a method to adjust the size of the image to fit
the dialog window when it has been changed already with mouse drag?
Thanks in advance!
chen
|
|
|
|
|
I suspect what you are asking is how to know the size of the dialog to draw the image. The answer is to draw in WM_ERASEBACKGRND, and use GetClientRect to find out the size to draw.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hi all!
I cannot create a thread. Help me do this please.
I want to do it with CreateThread function on Win 2000.
Could you give a simple example!
Thanks for your help!
Denis_aka_NULL
|
|
|
|
|
but there are a lot of samples ... here, just SEARCH (: !!!
----------------------------
my eng is bad, so am i .. (:
|
|
|
|
|
OK, thank you!
I've found it...
|
|
|
|
|
I have made an ActiveX control and I was working with it in a MFC application that uses the CMultiPageDHtmlDialog class.
The problem is that when I close the aplication an assert ocurs. The message is : dwCookie != 0 && dCookie <= (DWORD)m_nSize.
The assert is placed in a method called GetUnknow. It's ocurs when the application is disconnectin the events (I think). Any suggestion ?. Thanks.
|
|
|
|