to display thumbnails on ListView
-
how can i display the bmp, jpg, png image files as a thumbnails on MyListView. this is my code in ListView class: HANDLE hFile; hFile = CreateFile( "C:\\Documents and Settings\\B.Srinivas\\My Documents\\My Pictures\\SkinDlg.bmp", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile == INVALID_HANDLE_VALUE ) { MessageBox( "Invalid Handle", "ERROR", MB_ICONERROR); } else { // MessageBox( "File Opened successfully"); BYTE *Buffer; DWORD p=SetFilePointer( hFile, 0x003, NULL, FILE_BEGIN ); Buffer = new BYTE [2359350]; //LPDWORD lpNumberOfBytesRead = NULL; DWORD pp; bitmap.bmType=0; bitmap.bmWidth=1024; bitmap.bmHeight=768; bitmap.bmWidthBytes=1024; bitmap.bmPlanes=1; bitmap.bmBitsPixel=1; bitmap.bmBits=(LPSTR)Buffer; Bitmap image((WCHAR*)Buffer ,0); Bitmap *bmPhoto = NULL; CBitmap Bmp1; Bmp1.SetBitmapBits(&bitmap,Buffer) bmPhoto = new Bitmap( THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB ); // bmPhoto->SetResolution( 100,100);//image.GetHorizontalResolution(), image.GetVerticalResolution() ); //bmPhoto->SetResolution() hBmp=CreateBitmapIndirect((BITMAP FAR*)&bitmap); CDC *cdc=GetDC(); CDC *pMemDC=new CDC; pMemDC->CreateCompatibleDC(cdc); CBitmap *pOldBitmap=((CBitmap*)pMemDC->SelectObject(hBmp)); cdc->BitBlt(0,0,1024,768,pMemDC,0,0,SRCINVERT); pMemDC->SelectObject(&pOldBitmap); delete pMemDC; } please help me..:confused:
Regards, Srinivas
-
how can i display the bmp, jpg, png image files as a thumbnails on MyListView. this is my code in ListView class: HANDLE hFile; hFile = CreateFile( "C:\\Documents and Settings\\B.Srinivas\\My Documents\\My Pictures\\SkinDlg.bmp", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile == INVALID_HANDLE_VALUE ) { MessageBox( "Invalid Handle", "ERROR", MB_ICONERROR); } else { // MessageBox( "File Opened successfully"); BYTE *Buffer; DWORD p=SetFilePointer( hFile, 0x003, NULL, FILE_BEGIN ); Buffer = new BYTE [2359350]; //LPDWORD lpNumberOfBytesRead = NULL; DWORD pp; bitmap.bmType=0; bitmap.bmWidth=1024; bitmap.bmHeight=768; bitmap.bmWidthBytes=1024; bitmap.bmPlanes=1; bitmap.bmBitsPixel=1; bitmap.bmBits=(LPSTR)Buffer; Bitmap image((WCHAR*)Buffer ,0); Bitmap *bmPhoto = NULL; CBitmap Bmp1; Bmp1.SetBitmapBits(&bitmap,Buffer) bmPhoto = new Bitmap( THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB ); // bmPhoto->SetResolution( 100,100);//image.GetHorizontalResolution(), image.GetVerticalResolution() ); //bmPhoto->SetResolution() hBmp=CreateBitmapIndirect((BITMAP FAR*)&bitmap); CDC *cdc=GetDC(); CDC *pMemDC=new CDC; pMemDC->CreateCompatibleDC(cdc); CBitmap *pOldBitmap=((CBitmap*)pMemDC->SelectObject(hBmp)); cdc->BitBlt(0,0,1024,768,pMemDC,0,0,SRCINVERT); pMemDC->SelectObject(&pOldBitmap); delete pMemDC; } please help me..:confused:
Regards, Srinivas
I had to do this with an older reporting application I worked on - it dynamically loaded images from a database in the background and rendered them as thumbnails into a ListView control. The way I did it was to use custom draw with the ListView control, combined with a ImageList control. The ImageList control was used to pre-create (pre-allocate) and manage a very large bitmap, and the thumbnails were dynamically copied into it by loading the images and drawing them into the individual "icon cells" in the ImageList control. The ImageList control was then used to do indirect drawing directly into the ListView control using Custom Draw. I was able to get a pretty large amount of Thumbnails to work this way. I cannot release the code for it, but the concept for it is not patented! :) Peace!
-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
how can i display the bmp, jpg, png image files as a thumbnails on MyListView. this is my code in ListView class: HANDLE hFile; hFile = CreateFile( "C:\\Documents and Settings\\B.Srinivas\\My Documents\\My Pictures\\SkinDlg.bmp", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile == INVALID_HANDLE_VALUE ) { MessageBox( "Invalid Handle", "ERROR", MB_ICONERROR); } else { // MessageBox( "File Opened successfully"); BYTE *Buffer; DWORD p=SetFilePointer( hFile, 0x003, NULL, FILE_BEGIN ); Buffer = new BYTE [2359350]; //LPDWORD lpNumberOfBytesRead = NULL; DWORD pp; bitmap.bmType=0; bitmap.bmWidth=1024; bitmap.bmHeight=768; bitmap.bmWidthBytes=1024; bitmap.bmPlanes=1; bitmap.bmBitsPixel=1; bitmap.bmBits=(LPSTR)Buffer; Bitmap image((WCHAR*)Buffer ,0); Bitmap *bmPhoto = NULL; CBitmap Bmp1; Bmp1.SetBitmapBits(&bitmap,Buffer) bmPhoto = new Bitmap( THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB ); // bmPhoto->SetResolution( 100,100);//image.GetHorizontalResolution(), image.GetVerticalResolution() ); //bmPhoto->SetResolution() hBmp=CreateBitmapIndirect((BITMAP FAR*)&bitmap); CDC *cdc=GetDC(); CDC *pMemDC=new CDC; pMemDC->CreateCompatibleDC(cdc); CBitmap *pOldBitmap=((CBitmap*)pMemDC->SelectObject(hBmp)); cdc->BitBlt(0,0,1024,768,pMemDC,0,0,SRCINVERT); pMemDC->SelectObject(&pOldBitmap); delete pMemDC; } please help me..:confused:
Regards, Srinivas
vasu_sri wrote:
hFile = CreateFile( "C:\\Documents and Settings\\B.Srinivas\\My Documents\\My Pictures\\SkinDlg.bmp",
you needn't to directly read the bitmap from file. use
LoadImage()
image function to load a bitmap from file. This function will return u a handle of HBITMAP. And to Load JPG or GIF, you need to use the GDI+ class Image.nave
-
how can i display the bmp, jpg, png image files as a thumbnails on MyListView. this is my code in ListView class: HANDLE hFile; hFile = CreateFile( "C:\\Documents and Settings\\B.Srinivas\\My Documents\\My Pictures\\SkinDlg.bmp", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile == INVALID_HANDLE_VALUE ) { MessageBox( "Invalid Handle", "ERROR", MB_ICONERROR); } else { // MessageBox( "File Opened successfully"); BYTE *Buffer; DWORD p=SetFilePointer( hFile, 0x003, NULL, FILE_BEGIN ); Buffer = new BYTE [2359350]; //LPDWORD lpNumberOfBytesRead = NULL; DWORD pp; bitmap.bmType=0; bitmap.bmWidth=1024; bitmap.bmHeight=768; bitmap.bmWidthBytes=1024; bitmap.bmPlanes=1; bitmap.bmBitsPixel=1; bitmap.bmBits=(LPSTR)Buffer; Bitmap image((WCHAR*)Buffer ,0); Bitmap *bmPhoto = NULL; CBitmap Bmp1; Bmp1.SetBitmapBits(&bitmap,Buffer) bmPhoto = new Bitmap( THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB ); // bmPhoto->SetResolution( 100,100);//image.GetHorizontalResolution(), image.GetVerticalResolution() ); //bmPhoto->SetResolution() hBmp=CreateBitmapIndirect((BITMAP FAR*)&bitmap); CDC *cdc=GetDC(); CDC *pMemDC=new CDC; pMemDC->CreateCompatibleDC(cdc); CBitmap *pOldBitmap=((CBitmap*)pMemDC->SelectObject(hBmp)); cdc->BitBlt(0,0,1024,768,pMemDC,0,0,SRCINVERT); pMemDC->SelectObject(&pOldBitmap); delete pMemDC; } please help me..:confused:
Regards, Srinivas
Do you have a special intention for use of this code to open and load bmp file?
WhiteSky
-
Do you have a special intention for use of this code to open and load bmp file?
WhiteSky
i need some information. let me tell u exactly what i am doing. i am working on a project in which i have addresses of the starting sector and ending sector of an image file. Using those two sector addresses of the hard disk, I have to display that image as a thumbnail preview on a list pane just like windows thumbnail view. i want to know how I can resolve this query progrmatically in VC++ without using any third party tool. can u please help me on this? thanks in advance.
Regards, Srinivas
-
i need some information. let me tell u exactly what i am doing. i am working on a project in which i have addresses of the starting sector and ending sector of an image file. Using those two sector addresses of the hard disk, I have to display that image as a thumbnail preview on a list pane just like windows thumbnail view. i want to know how I can resolve this query progrmatically in VC++ without using any third party tool. can u please help me on this? thanks in advance.
Regards, Srinivas
You have two addresses of start and end of a file on the harddisk and you want to make a bmp file(thumbnail)of them ,right?
WhiteSky
-
You have two addresses of start and end of a file on the harddisk and you want to make a bmp file(thumbnail)of them ,right?
WhiteSky
-
yes. i am even able to create the file using that data (by using
CreateFile()
function). but, before saving that data, i want to show the preview of that image. how can i do it?Regards, Srinivas
I think its a good article for you ;) http://www.codeproject.com/listctrl/Simple_Thumbnail_Listview.asp[^]
WhiteSky