|
Thanks for your help, i really need it!
|
|
|
|
|
I work with microscope and i have avi file from surface.
I need intensity of every pixel. I need it for mathematical manipulations with images (filters and other stuff). So, i open avi file and take a frame from avi like
LPBITMAPINFOHEADER lpBitmap = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pVideoFrame, nFrame);
and save it as txt file, which works for 24 and 32 bpp.
But i need 8 bpp and 16 bpp bitmaps (little size)
//Code
int BytesPerPixel = (lpBitmap->biSizeImage)
/(lpBitmap->biHeight * lpBitmap->biWidth);
int WidthBytes = lpBitmap->biWidth * BytesPerPixel;
int size = sizeof(BITMAPINFOHEADER)
+ sizeof(RGBQUAD) * lpBitmap->biClrUsed;
BYTE *Bits = (LPBYTE)lpBitmap
+ size;
BYTE * ScanLine;
BYTE * Data;
unsigned long Red, Green, Blue;
CStdioFile skadr;
CString string;
skadr.Open(filename, CFile::modeCreate|CFile::modeWrite);
for( int y = lpBitmap->biHeight; y>0; --y )
{
ScanLine = Bits + (WidthBytes * (y-1));
Data = ScanLine;
for( int x = 0; x<lpbitmap->biWidth - 1; ++x )
{
LPRGBQUAD Quad = (LPRGBQUAD) Data;
Blue = Quad->rgbBlue;
Green = Quad->rgbGreen;
Red = Quad->rgbRed;
unsigned long color = (Red * 0.299)
+ (Green * 0.587)
+ (Blue * 0.114);
string.Format("\t %d", color);
skadr.WriteString(string);
Data += BytesPerPixel;
}
string.Format("\n" );
skadr.WriteString(string);
}
|
|
|
|
|
The thing you have to consider is, what do you want to achieve ? The way you're writing the file, you're getting an 8 bit greyscale image, if you put this info into an 8 bit bitmap with a palette that went evenly from 0,0,0 to 255,255,255, it would work. You're only writing out one colour value as far as I can see, and you're now correctly calculating the grey value. Therefore making your bitmap 8 or 16 bit internally will only result in messy calculations to get to the same point you're reaching now. Please correct me, but I believe you're writing out one unsigned char per colour, although you're making the variable an unsigned long, it will still be between 0 and 255, yes ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Yes, it still between 0...255.
And more, i compared it for 24 and 32 bpp with using GetPixel function
BYTE grayValue = (BYTE)(int)((GetRValue(clr) + GetGValue(clr) + GetBValue(clr)) / 3),
and it was the same.
But for 8 bitmap, then i using GetPixel it was like
125 125 125 (Red Green Blue)
and for my code it was
31 31 31
Why? I don't know
Yes, i need grayValue for every pixel
But i don't neen GetPixel(), because it work with handle (hDC, DC and other),
i need information only from bitmap (avi frame->LPBITMAPINFOHEADER)
But i haven't ideas how to wrote simple code for 8 and 16 bpp
|
|
|
|
|
Following the documentation, the ShowHTMLDialogEx() function should
support the Print Template behavior in the loaded HTML.
However, there is no example nor explanation about this feature.
How can I pass the dialogArguments object and its members, like
__IE_BrowseDocument, to the loaded HTML?
|
|
|
|
|
I have a dialog which I use as a toolbar. On this dialog are drawn buttons using the CreateWindow function so that they can be drawn dynamically and they are sent the BM_SETIMAGE so that I can draw a different bitmap on each. This all works fine, I can add and remove buttons anywhere I want on this toolbar dialog. This is probably a really simple question, how do I handle them being pressed?
Thanks for any help in advance,
Nick
|
|
|
|
|
Hi,
How can i determine the size of the disk drive that the c: partition is on?
I know how to get the partition info for drive c:, but i need the whole drive size.
The code needs to work in 95+ and nt+
Thanks for any pointers to info
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Greetings!!!
Please tell me any other good web-sites regarding VC++/MFC, other than the following sites:
www.funducode.com
www.codeguru.com
www.codeproject.com
www.mindcracker.com
cheers...
Imran Farooqui
|
|
|
|
|
Someone at school told me about www.planet-source-code.com, but I dont know if its any good. I havent checked it out yet.
-Raffi
|
|
|
|
|
devx.com
experts-exchange.com
San
|
|
|
|
|
in my program i am reading files, searching for a particular line.. if i find this line i would like to add the line after the line i'm reading..
this whole shebang works well if i use two different files (reading a line, parsing) -> writing this line and the added line if it's the correct one..
if i would like to do this in the same file it doesn't work..
thanks in advance
bernhard
"Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|
|
You can't insert data in the middle of a file, you can either overwrite existing data or append to the end of file. As you have found out, you need two files to "simulate" insertion.
|
|
|
|
|
just to make it sure.. if i want to insert data in the middle of the file i have to make a temp file.. do whatever i want with that file.. and if everyhting is nice i replace the original with the temp file ???
thanks for your answer, a "this helped" for you comes soon
Bernhard
"Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|
|
Yes, basically the method is to copy everything before the insertion point to temp file, write the data to be inserted, and then copy the rest of the original data. If you need to do lots of insertions you should consider using some kind of indexed file structure or a database engine. If that isn't possible, do the insertions in memory and dump only the final data to file.
|
|
|
|
|
I want to display this Dialog at the left corner of the screen when it first display.i add these code to the CMyDialoy::OnInitDialog()
....
MoveWindow(0,0,300,300);
....
but it can't display right.
if i add a button in this dialoy,and add a button handler for it with the above code.when i click this button,the dialog will move the right location.
where is the problem?
|
|
|
|
|
Try this:
CRect rc;
GetWindowRect(&rc);
MoveWindow(0, 0, rc.Width(), rc.Height(), TRUE);
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
it don't work correctly too.the dialog is still displayed at the default coordinate. not the left corner (0,0)
|
|
|
|
|
Hello, the codegurus around the world.;)
MoveWindow works well in my code.
Which line did you put MoveWindows.
MoveWindow should be put before return TURE or FALSE in OnInitDialog.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Any where, but you need to take care, because move window need a HWND, if your window is not created yet, you will get an Assert....
Cheers!!!
Carlos Antollini.
Today is Friday?
No Bob...
|
|
|
|
|
Thanks all.
I have found the reason.
I call the MoveWindow function with parameters (0,0,200,200),
if i change it to (1,1,200,200).it will locate rightly.
if the first and the second parameters are both zero
then this function will only modified the Dialog's Width and Height,don't modified the window's left_top corner coordinate
but how i enforce the dialog move to (0,0) ?
|
|
|
|
|
Try the windows API version of the function. There's nothing (that I saw) on the MSDN CD about this.
Try this and see if it will position correctly:
::MoveWindow(this->GetSafeHwnd(), 0, 0, 200, 200, TRUE);
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
With SetWindowPos....
BOOL SetWindowPos(
HWND hWnd,
HWND hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
UINT uFlags
);
Cheers!!!
Carlos Antollini.
Is Today Friday?
No Bob!!!
|
|
|
|
|
Not when you're in a CWnd class to begin with.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
CDialog automatically calls CenterWindow() for you after OnInitDialog() returns if the dialog is at coordinates (0,0). You'll need to put it at some other position (like (1,1) or (0,1) or whatever) to avoid CDialog repositioning it for you.
--Mike--
http://home.inreach.com/mdunn/
This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use.
your with and
|
|
|
|
|
VC++6, W2K
Hi,
I am trying to use #import for 2 simliar components.
#import "E:\tools\x\Record.dll" no_namespace
#import "E:\tools\x\AudioFile.dll"
I am getting an error
d:\lab\try2rec\debug\audiofile.tli(59)... overloaded function differs only by return type
can someone please let me know the problem
San
|
|
|
|
|