Exactly 24bpp. But what I meant is I have 8 bits of R,8 bits of G and 8 bits of B seperately in seperate arrays. Now with respect to the routine what you have given me last time http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^] what are the modifications I have to do
jossion
Posts
-
BITMAPINFO + Colour video -
BITMAPINFO + Colour video8 bit per pixel in RGB format.I have three arrays of unsigned char for each R,G and B values.
-
rendering video8 bit per pixel in RGB format
-
BITMAPINFO + Colour videoHi all, This is with reference to an old message posted by me which you can find here http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^] For the past one year this piece of code which Mr.Mark gave me; satisfied my requirements excellently. Now I have come up with a problem of displaying colour video. I will need help once again in modifying the code to colour mode. The main problem is how I should arrange the pixels and where to write it. What are the BITMAPINFO parameters that I have to change. Hope to get a reply at the earliest.
-
rendering videoHi Salsbery, For the past one year the piece of code you gave me satisfied my requirements excellently. Now I have come up with a problem of displaying colour video. I will need help once again in modifying the code to colour. The main problem is how I should arrange the pixels and where to write it. What are the BITMAPINFO parameters that I have to change. Hope to get a reply at the earliest.
-
rendering videothank you very much. This is the first time I am getting a complete solution from Codeproject. cheers.
-
rendering videoI have pixel values of successive frames of video stored in int disp_frame[50][144[176], 50 buffers of size 176X144. Under a timer of 40ms I was doing all the stuff which i posted. Previously I was using setpixel to draw the video. Now for better speed I thought of doing BitBlt. So there came a ncessity to convert the raw pixel values to bitmap. That is what should happen in the rendering section. Creating DC,then Creating DIB then copying to memory DC, then using BitBlt or optional zooming with StretchBlt. I know that there are still excellent ways of doing it. But I thought of learning all techniques by coding it and seeing the performance. So I would like you to fill the rendering area with BitBlt(including routines for DC creation) for displaying pixels in disp_frame.As I have read the pixel values should be copied to (void**)&pBitmapBits. Basically I am not a person with programming background. that's why my code might have irritated you a bit. Anyhow a small apology for my mistakes. bitmap is of type BITMAPINFO *bitmap.
-
rendering videoFollowing is the piece of code i am using to render grayscale video onto screen. The pixel values are stored as 'int' in the variable disp_frame whose declaration is given below. 50 pixel buffers of size 176 X 144 is used. I thought of creating bitmap out of these pixels and then use BitBlt to render it to the screen. But the CreateDIBSection is creating an exception when running in Debug code. It should be some syntax error. Could anyone debug it out. int p=0,i=0,j=0,q=0; extern int disp_frame[50][144][176]; /////////////////////// BITMAPINFOHEADER bmi; BITMAPINFO bm; RGBQUAD rgbarray[256]; bmi.biSize = sizeof(BITMAPINFOHEADER); bmi.biWidth = 176; bmi.biHeight = 144; bmi.biPlanes = 1; bmi.biBitCount = 8; bmi.biCompression = BI_RGB; bmi.biSizeImage = 0; bmi.biXPelsPerMeter = 0; bmi.biYPelsPerMeter = 0; bmi.biClrUsed = 0; bmi.biClrImportant = 0; bm.bmiHeader = bmi; for (int color_index = 0; color_index < 256; color_index++) { rgbarray[color_index].rgbBlue = i; rgbarray[color_index].rgbGreen = i; rgbarray[color_index].rgbRed = i; rgbarray[color_index].rgbReserved = 0; } bm.bmiColors[1] = rgbarray[0]; ///////////////////// CRect rcClient; GetClientRect(rcClient); // See Note 1 rcClient.right=176; rcClient.bottom=144; /*****************Doubtful routine starts here******* HDC hDC; hDC = CreateDC("DISPLAY",NULL,NULL,NULL); HDC memDC = CreateCompatibleDC(hDC); CreateDIBSection(hDC,bitmap,DIB_PAL_COLORS,ppbits,NULL,0); HBITMAP memBM = CreateCompatibleBitmap(hDC,176,144); SelectObject(memDC,memBM); BitBlt(memDC,150,100,176,144,hDC,0,0,SRCCOPY);
-
A query in bitmap routineThe error message was Unhandled exception in decoder.exe(GDI32.dll): 0xc0000005 : Access Violation the declaration for ppbits was void **ppbits. Once this CreateDIBSection works i thought of filling ppbits with pixel values. That's why that particular piece of code is not available
-
A query in bitmap routinertant = 0; bm.bmiHeader = bmi; for (int color_index = 0; color_index < 256; color_index++) { rgbarray[color_index].rgbBlue = i; rgbarray[color_index].rgbGreen = i; rgbarray[color_index].rgbRed = i; rgbarray[color_index].rgbReserved = 0; } bm.bmiColors[1] = rgbarray[0]; ///////////////////// CRect rcClient; GetClientRect(rcClient); // See Note 1 rcClient.right=176; rcClient.bottom=144; CDC MemDC,*pDC; CBitmap MemBitmap,*drawmem; pDC = this->GetDC(); // Get Current DC MemDC.CreateCompatibleDC(pDC); CreateDIBSection(MemDC,bm,DIB_RGB_COLORS,disp_frame,NULL,0); CBitmap *pOldBitmap =MemDC.SelectObject(&MemBitmap); pDC->BitBlt(150,100,176,144,&MemDC,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); ReleaseDC(pDC); } This was the piece of code which was posted previously. But the CreateDIBSection code CreateDIBSection(MemDC,bm,DIB_RGB_COLORS,disp_frame,NULL,0); was having MemDC is a CDC type. But actually it should be HDC type. So I have rewritten the code as HDC hDC; hDC = CreateDC("DISPLAY",NULL,NULL,NULL); HDC memDC = CreateCompatibleDC(hDC); CreateDIBSection(hDC,bitmap,DIB_PAL_COLORS,ppbits,NULL,0); HBITMAP memBM = CreateCompatibleBitmap(hDC,176,144); SelectObject(memDC,memBM); BitBlt(memDC,150,100,176,144,hDC,0,0,SRCCOPY); But CreateDIBSection is creating exception. What could be the reason. Basically I could not get the difference between CDC and HDC. Could anyone give a clear solution to my problem. I am actually trying to display a grayscale image which exists as R=G=B values in memory.
-
how to add an image in the form in vc++??In visual C project (MFC type) go to insert menu and select bitmap option. Browse for your picture file and add it.Under resources tab in the project navigator check the ID of the bitmap file. Then under OnPaint() function add this piece of code. CPaintDC dc(this); CBitmap bmp , *poldBmp; CDC memdc; bmp.LoadBitmap(IDB_BITMAP1); // IDB_BITMAP1 is the ID of the bitmap loaded mdmdc.CreateCOmpatibleDC(&dc); poldBmp= memdc.SelectObject(&bmp); dc.BitBlt(10,10,47,47,&memdc,0,0,SRCCOPY); memdc.SelectObject(poldBmp); //Do not call CDialog::Onpaint() for painting
-
A query in bitmap routineBelow is the code snippet I wrote for displaying pixel values onto the screen in MFC. The pixel values are stored in buffer disp_frame. But nothing appears on screen. Could anyone debug this code. void CBluetooth_decoderDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default int p=0,i=0,j=0,q=0; // extern int disp_frame[50][144][176]; /////////////////////// BITMAPINFOHEADER bmi; BITMAPINFO bm; RGBQUAD rgbarray[256]; bmi.biSize = sizeof(BITMAPINFOHEADER); bmi.biWidth = 176; bmi.biHeight = 144; bmi.biPlanes = 1; bmi.biBitCount = 8; bmi.biCompression = BI_RGB; bmi.biSizeImage = 0; bmi.biXPelsPerMeter = 0; bmi.biYPelsPerMeter = 0; bmi.biClrUsed = 0; bmi.biClrImportant = 0; bm.bmiHeader = bmi; for (int color_index = 0; color_index < 256; color_index++) { rgbarray[color_index].rgbBlue = i; rgbarray[color_index].rgbGreen = i; rgbarray[color_index].rgbRed = i; rgbarray[color_index].rgbReserved = 0; } bm.bmiColors[1] = rgbarray[0]; ///////////////////// CRect rcClient; GetClientRect(rcClient); // See Note 1 rcClient.right=176; rcClient.bottom=144; CDC MemDC,*pDC; CBitmap MemBitmap,*drawmem; pDC = this->GetDC(); // Get Current DC MemDC.CreateCompatibleDC(pDC); CreateDIBSection(MemDC,bm,DIB_RGB_COLORS,disp_frame,NULL,0); CBitmap *pOldBitmap =MemDC.SelectObject(&MemBitmap); pDC->BitBlt(150,100,176,144,&MemDC,0,0,SRCCOPY); MemDC.SelectObject(pOldBitmap); ReleaseDC(pDC); }
-
Allocating memory using calloc.Thanks for the valuable information
-
Allocating memory using calloc.I am a bit curious about why to use new in MFC. What is the danger which is avoided by using 'new' and why such a precaution in MFC. I am almost unaware about MFC and its fundamentals.. That's why I am curious about the above issue
-
Allocating memory using calloc.I am not checking calloc value. But in debug mode I have watched the pointers. They are valid ones. At the same time I would like to mention that I am not freeing them anywhere in the code because this buffer is used cyclically throughout the runtime of the code by the worker thread. The pointer is duplicated for use by the worker thread. char *store_buf; store_buf=source_buf;
-
Allocating memory using calloc.Hi friends, I am trying to allocate around 3 sets of nearly 1.8MB of memory with calloc inside OnInitDialog() function of MFC. I used a memory leak detector tool and before I could start the worker threads I was able to see memory leaks in the lines which I used to allocate the memory mentioned above. Is there any issue in using calloc for memory allocation more than 64KB. I am using Win2000 with Visual studio 6.0 (VC++). Following is the code snippet I used. char *source_buf; unsigned long size = 9001; source_buf = (char*) calloc((size*200),sizeof(char));
-
Creating user defined messages and events in MFCHi, I would like to get hints as to how to create messages in MFC. I wanted to sense the serial port buffer and then if the bytes received is above a threshold I would like to post a message and handle it with a function. How could it be done. The main issue is creating message or events to be handled.
-
Bitmap creation in internal bufferI have stored monochrome pixel values of an image in a buffer of type int**. Now I would like to create a bitmap out of it to use BitBlt() function to display it. How do I create a bitmap out of raw pixel values.
-
Timer in MFCI am using CreateThread() function to create worker threads. Are there any other ways to create threads in MFC applications. Why I have this doubt is because my application is utilizing full 100% of CPU all the time. My application has one serial port reading thread which should take only very little CPU another a fully mathematical thread and third a display thread.
-
Timer in MFCI have a 3 thread MFC application. Out of these one sub thread should be used for displaying video at intervals of 40ms. How do i create a periodic timer to accomplish this job. I have seen the SetTimer function. How to manage the timer from the display thread. How to get the parameters such as HWND,TimerProc parameter etc.