|
Damnit, you're so fast!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
pallini..thnx..but i need a full running code for comparing 2 bitmaps..
i have posted my code but i cant understand what is wrong in my code...
can you help please..
1.
void CPixelView::OnDraw(CDC* pDC)
{
CPixelDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
{
COLORREF color[255][255],color1[255][255];
CBitmap bitmap,bitmap1;
CString file1,file2,strText;
file1.Format("C:\\1.bmp");
file2.Format("C:\\3.bmp");
CDC dcMemory,dcMemory1;
int r[255][255],R[255][255];
// 1st image HBITMAP hBitmap1 = (HBITMAP)::LoadImage(NULL,file1,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE );//| LR_CREATEDIBSECTION);
//2nd image HBITMAP hBitmap2 = (HBITMAP)::LoadImage(NULL,file2,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE );
// Attach the loaded image to the CBitmap object.
bitmap.Attach(hBitmap1);
bitmap1.Attach(hBitmap2);
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bitmap);
dcMemory1.CreateCompatibleDC(pDC);
dcMemory1.SelectObject(&bitmap1);
pDC->BitBlt(0,0,200,200,&dcMemory,0,0,SRCCOPY);
pDC->BitBlt(0,0,300,700,&dcMemory1,0,0,SRCCOPY);
//for all the pixels
for(int i=0;i<48;i++)
{
for(int j=0;j<48;j++)
{
HDC hDC = ::GetDC(this->GetSafeHwnd());
color[i][j] = ::GetPixel(hDC,i,j);
::ReleaseDC(this->GetSafeHwnd(), hDC);
r[i][j]=GetRValue(color[i][j]);
HDC hDC1 = ::GetDC(this->GetSafeHwnd());
color1[i][j] = ::GetPixel(hDC1,i,j);
::ReleaseDC(this->GetSafeHwnd(), hDC1);
R[i][j]=GetRValue(color1[i][j]);
}
}//got the pixel values
}
}
|
|
|
|
|
kaushal kishore sharma wrote: allini..thnx..but i need a full running code for comparing 2 bitmaps
He just posted the code.
|
|
|
|
|
Well, you're "getting there";
Me thing you do not need to keep arrays of COLORREF or the r and R arrays
You should be able to get the size of the bitmaps dynamically (because a bitmap of 48 pixel is really small)
No need to get the DC twice.
Now that you have the color for the same pixel position in both bitmaps; what should you be doing with them ? compare them ? maybe ?
This signature was proudly tested on animals.
|
|
|
|
|
thank you for the reply.
can you tell how to make changes in the code. I am studying VC++ so not too much knowledge about the language.So can you help me with the code.
Yes i am comparing both bitmap for checking whether both images are same or different.
Thank You
kaushal kishore Sharma
kaushal..
|
|
|
|
|
Ingenious.
|
|
|
|
|
And can we use of this code for other formats like jpg?
|
|
|
|
|
Hamid. wrote: And can we use of this code for other formats like jpg?
Nope. You have to change it:
if ( jpegImage1 == jpegImage2) ...
Details for all image formats on www.cpallini.freeproductz.com.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I decided to made a supplement for your magic site.
|
|
|
|
|
how many times do you need to post this same question?
|
|
|
|
|
Of course you can use of CImage class for read your bitmap files and like your code you can use of two loop(See CImage::GetPixel) I think its easy than your code.
|
|
|
|
|
|
Hi,
I am developing a dialog based application in VC++.
In that application for all the dialogs i need to use ActiveX controls.
If i register the coresponding .ocx files and use my application it is working fine. But my problem is if i unregister the .ocx files that dialog is not opening also. Functionality will not work that is ok. but why dialog is not opening at all?
|
|
|
|
|
After adding a toolbar, when drawing the client, I need to adjust the rect which is returned in
GetClientRect .
Is there any way to make it transparent?
logics
|
|
|
|
|
Hope this helps.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
I mean that make GetClientRect return the client rect exclude the toolbar rect.
logics
|
|
|
|
|
But your question spoke about making it transparent
...anyway, to get the actual client area (drawing area), you can create it as a child window that covers the entire space except the toolbars etc. and put all your controls inside that child window. Then a call to GetClientRect with child window as a parameter will give you the desired rect (you can take a look at this[^]example). I am not aware of any other more sophisticated way to achieve this.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
void CPixelView::OnDraw(CDC* pDC)
{
CPixelDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
{
COLORREF color[255][255],color1[255][255];
CBitmap bitmap,bitmap1;
CString file1,file2,strText;
file1.Format("C:\\1.bmp");
file2.Format("C:\\3.bmp");
CDC dcMemory,dcMemory1;
int r[255][255],R[255][255];
HBITMAP hBitmap1 = (HBITMAP)::LoadImage(NULL,file1,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE );//| LR_CREATEDIBSECTION);
HBITMAP hBitmap2 = (HBITMAP)::LoadImage(NULL,file2,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE );
// Attach the loaded image to the CBitmap object.
bitmap.Attach(hBitmap1);
bitmap1.Attach(hBitmap2);
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bitmap);
dcMemory1.CreateCompatibleDC(pDC);
dcMemory1.SelectObject(&bitmap1);
pDC->BitBlt(0,0,200,200,&dcMemory,0,0,SRCCOPY);
pDC->BitBlt(0,0,300,700,&dcMemory1,0,0,SRCCOPY);
//for all the pixels
for(int i=0;i<48;i++)
{
for(int j=0;j<48;j++)
{
HDC hDC = ::GetDC(this->GetSafeHwnd());
color[i][j] = ::GetPixel(hDC,i,j);
::ReleaseDC(this->GetSafeHwnd(), hDC);
r[i][j]=GetRValue(color[i][j]);
HDC hDC1 = ::GetDC(this->GetSafeHwnd());
color1[i][j] = ::GetPixel(hDC1,i,j);
::ReleaseDC(this->GetSafeHwnd(), hDC1);
R[i][j]=GetRValue(color1[i][j]);
}
}//got the pixel values
}
}
i am inserting 2 images in this ondraw command and i want to calculate the pixel of both the pictures to compare it...
can anyone tell why it is not working..complilng is done correctly but when exceute it lead to open and window with error file..
please tell asap ....
thank you..
|
|
|
|
|
kaushal kishore sharma wrote: Can anyone tell what is wromg with this code
Yes, it is badly formatted.
BTW:
(1) Be more specific with question title.
(2) Use the code block button to surround code snippets with <pre> tags.
kaushal kishore sharma wrote: but when exceute it lead to open and window with error file..
(3) Report exactly what the error was.
kaushal kishore sharma wrote: please tell asap ....
(4) urgentz questions go automatically down to the bottom of the reply stack.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Why dont you use GetDIBits()??
BTW Please use Code block tags for posting code.
Regards,
Sandip.
|
|
|
|
|
Hi all,
we have a SDK for our products, which was placed under the 'program files' folder up to now. Since MS changed the access rights under Vista, I get a message box asking me whether to restart Visual Studio with elevated permissions, when I open a project.
Now there are two solutions for this problem:
1. Place the SDK with all sample projects somewhere else (but where?), or
2. Set file and folder access rights (How?)
Any thoughts?
jung-kreidler
|
|
|
|
|
You can change permissions using Windows explorer.
Find the parent folder, right click, chose properties.
Go to the security tab and set the appropriate access
permissions for the apropriate users and/or groups.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, thank you. This is the manual way, but we would like to avoid making thinks for our customers more and more complex. I've found icacls to set permissions during setup. What's MS going to do with their SDK's. Do they place them somewhere else (and where), or do they set permissions?
jung-kreidler
|
|
|
|
|
jung-kreidler wrote: What's MS going to do with their SDK's
The latest SDK by default is installed at
C:\Program Files\Microsoft SDKs\Windows\v6.1
I'm not sure what permissions are set since SDK stuff only has to be read-only.
Setting folder permissions is the job of installers. That's why installers
generally need to run with elevated privileges.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks! That's enough info up to now.
InstallShield (installscript) seems not to be capable of setting permissions, so I wrote my own grant.exe... At the moment I'm struggling with the installscript to call my grant .
Happy coding!
jung-kreidler
|
|
|
|
|