|
image shows a different color with dialog box
|
|
|
|
|
But you load an image for button,right?
|
|
|
|
|
yes but the image is not transparent with button in vista. Incase of windows xp its looking fine
|
|
|
|
|
Does this help?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello and good day to all,
I am currently working on a project where I can patch together a number of bitmaps and make them as one. It also has options of resizing the bitmap before saving it by removing some bytes here and there. Because of the limitation in CreateCompatibleBitmap() on large files, what I do is I store the needed data on BITMAPINFOHEADER and BITMAPFILEHEADER and I also have a char * for saving the actual data of the bitmap.
Here is where the problem starts. I have a 3200 x 3200 and easily saves it on a bitmap, then I can also reload and resize and make it into half (1600 x 1600) then saves it and it works(I can see it in the explorer). However, when I resize it to a third of a size (1067 x 1067), the bitmap file (when opened in explorer) won't show and even load. But when I resize it to a fourth of the original size it shows. These problem also occurred on the one-sixth of the original.
BmapFHeader.bfType = 'MB';<br />
BmapFHeader.bfSize = (gBitMap.width * gBitMap.height * 3) + 54; <br />
BmapFHeader.bfReserved1 = 0x00;<br />
BmapFHeader.bfReserved2 = 0x00;<br />
BmapFHeader.bfOffBits = 54;<br />
<br />
BmapIHeader.biSize = 40;<br />
BmapIHeader.biWidth = gBitMap.width;<br />
BmapIHeader.biHeight = gBitMap.height;<br />
BmapIHeader.biPlanes = 1; <br />
BmapIHeader.biBitCount = 24; <br />
BmapIHeader.biCompression = BI_RGB;<br />
BmapIHeader.biSizeImage = gBitMap.width * gBitMap.height * 3;<br />
BmapIHeader.biXPelsPerMeter = 0x00;<br />
BmapIHeader.biYPelsPerMeter = 0x00;<br />
BmapIHeader.biClrUsed = 0x00;<br />
BmapIHeader.biClrImportant = 0x00;
Above is the BITMAPINFOHEADER and BITMAPFILEHEADER and I write it to the file, and afterwards I write the data. I double checked every parameter but all of them seems correct. Its just weird that it works on certain sizes while does not work on some. I am hoping that someone here might know the answer. Please help me out! Thank you very much!
Edit: Already solved! 24bitmaps that I am processing needs to have a row which is divisible by 4. Many thanks to Whitesky for the immediate attention and help, Naveen.R for the suggestions, and specially to Paresh Chitte for the great articles that solved my problem. Thanks also to the others for the time and effort!
-- modified at 3:15 Monday 9th July, 2007
|
|
|
|
|
|
Thanks! I already read this one though. But unfortunately it did not solve my problem. It's just weird that there are certain sizes of the bitmap that it can't display.
|
|
|
|
|
Does CImage::Save solve your problem of course it saves uncompressed bitmap but you have other choices like jpg,...
|
|
|
|
|
I just use WriteFile() and write the BITMAPFILEHEADER and BITMAPINFOHEADER and then the char * containing the data. I am thinking maybe I got something wrong off my bitmap header, but it works on other values like 3200x3200 and 1600x1600. But when it comes to 1067x1067 it does not. I checked the char * to see whether I got the size of data wrong but it is right. Checking the bitmap file that I produced(1067x1067) it seems right. I just dont get it why it doesnt display. I pasted below the header of the bitmap file for reference. Thank you for the help and time!
42 4D E1 1D 34 00 00 00 00 00 36 00 00 00 28 00 00 00 2B 04 00 00 2B 04 00 00 01 00 18 00 00 00 00 00 AB 1D 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
|
It seems your problem solved.;)
|
|
|
|
|
Yes it has been! Thanks a lot for all your help and time to solve this problem!
|
|
|
|
|
Try to keep height and width of your bmp in multiple of 4.
Hope this will help you.
Regards,
Paresh.
|
|
|
|
|
Yes it does help! though the application's requirements are to display it in different multiples. Really tough. I'm just wondering why the bitmap won't work on other multiples besides 2 and 4. Thanks a lot for the help though!
|
|
|
|
|
|
Wow nice articles! I might find the answer in one of them. Thanks Paresh for the help!
Edit: Your right! It must be on a multiple of 4! Nice research on the articles! Thanks a lot for the help!
|
|
|
|
|
Llasus wrote: I'm just wondering why the bitmap won't work on other multiples besides 2 and 4
For bitmap's the pixels that represent one row should be a multiple of four.
Suppose you have a bitmap of bit dept 24 and width 150. In that case the total byte required to represent on row is
( 24/8 )*150 = 450. But this is not divisible by four. In this case you have to add dummy bytes in the end of each row. In the above example the number of dummy bytes will be
int nBytesNeed = 4 - (450%4);// = 2
so append a 2 bytes at the end of each row. Thus for each row the number of bytes will be 452.
|
|
|
|
|
Yupyup! I realized that just earlier. Im gonna do some revisions for my code now for that extra padding needed. Thank you for your help!
|
|
|
|
|
I wanted to write some code or use a library to take the screen as an array of pixels and to locate a specific pixel by x-y axis of the screen, so for example I am running a program on the side which displays its output as graphics, like a card game, now I want to read the cards, in order to do this I will have to read the pixel at a specific location and see if it matches with a different array to "figure" out which card was displayed, and then have the program take the appropriate action. For example if it is poker and the cards are good to press a button to call/raise instead of folding and vice versa. Basically I need to read the screen, or a window and interpret the visual state.
|
|
|
|
|
Im not sure do you need to GetPixel ?
|
|
|
|
|
Just a suggestion. You can start by studying all about CDC.
CWnd* MyDlg;<br />
CDC* MyDC;<br />
<br />
MyDlg = GetDlgItem(IDC_DISPLAYPANEL);
MyDC = MyDlg->GetDC();
From here by getting the CDC of your dialog, you can obtain it's bitmap by using CreateCompatibleBitmap() and obtain the data you'll need from your Bitmap object. Haven't tried it yet, though I am sure that these are the ones you will be needing for your application. Hope that helps.
|
|
|
|
|
I'm not sure about the above two methods.. And I'm sure they work fine but I think that getting pixel values is quite intensive on the CPU/GPU, especially if you are getting a lot of pixel values at the same time..
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Yup, I was thinking about the heavy processing that it will require, specially the comparison. But if it is what was required of his application then it will be tough. Maybe he can just do the computation and comparison by using variables inside the program, instead of capturing the image outside.
|
|
|
|
|
Llasus wrote: Yup, I was thinking about the heavy processing that it will require
Yes it would .. another thing to do would be to inject a DLL into the application and then monitor the messages to and from the window.. With this he could then send messages to the window to do certain tasks (if this is supported), and if, for example, there are custom messages, to get the numbers on certain cards.
Hope this helps!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Dear all
i have a issue here, please help me. thanks.Build : warning : failed to (or don't know how to) build 'C:\Documents and Settings\Administrator\Desktop\Particle paper\VC++\facerecognition\ÀûÓÃVFW½øÐÐÊÓƵ²¶×½\VFWImageProcessor.cpp'
Compiling...
VFWImageProcessor.cpp
fatal error C1083: Cannot open source file: 'C:\Documents and Settings\Administrator\Desktop\Particle paper\VC++\facerecognition\ÀûÓÃVFW½øÐÐÊÓƵ²¶×½\VFWImageProcessor.cpp': No such file or directory
Error executing cl.exe.
FaceDetect.exe - 1 error(s), 1 warning(s)
unenglish character in directory above is another language of other country, but i couldn't find in directory. so how i can find it and replace english language. thanks a lot.
Li Zhiyuan
9/07/2007
|
|
|
|
|
Are you sure you have this file?
|
|
|
|