LoadBitmap returns NULL
-
I want to display a JPEG file at the picture control. I created a memory variable m_hBitmap at the CDialog class and have the interface to process the following code when the Open button is clicked. But line #2 always returns NULL. CString file_name = "c:\\gis\\aspjpeg\\root.jpeg"; //line #1 m_hBitmap = (HBITMAP)::LoadBitmap(NULL, file_name); //line #2 m_thumbnail.SetBitmap(m_hBitmap); //line #3 Elizabeth
-
I want to display a JPEG file at the picture control. I created a memory variable m_hBitmap at the CDialog class and have the interface to process the following code when the Open button is clicked. But line #2 always returns NULL. CString file_name = "c:\\gis\\aspjpeg\\root.jpeg"; //line #1 m_hBitmap = (HBITMAP)::LoadBitmap(NULL, file_name); //line #2 m_thumbnail.SetBitmap(m_hBitmap); //line #3 Elizabeth
are you sure
LoadBitmap
can load jpg files ?
Maximilien Lincourt "Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
-
I want to display a JPEG file at the picture control. I created a memory variable m_hBitmap at the CDialog class and have the interface to process the following code when the Open button is clicked. But line #2 always returns NULL. CString file_name = "c:\\gis\\aspjpeg\\root.jpeg"; //line #1 m_hBitmap = (HBITMAP)::LoadBitmap(NULL, file_name); //line #2 m_thumbnail.SetBitmap(m_hBitmap); //line #3 Elizabeth
Are you sure that the first parameter to
LoadBitmap()
can be NULL? The docs do not indicate such. Have you checked the return value ofGetLastError()
? That might tell you exactly what is happening! I suspect Max's comment is more in line with what is happening.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
Are you sure that the first parameter to
LoadBitmap()
can be NULL? The docs do not indicate such. Have you checked the return value ofGetLastError()
? That might tell you exactly what is happening! I suspect Max's comment is more in line with what is happening.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
I tried openning a bitmap file, but still getting a NULl return. Here is the updated code: CString file_name = "c:\\gis\\aspjpeg\\new_file.bmp"; //line #1 m_hBitmap = (HBITMAP)::LoadBitmap(NULL, file_name); //line #2 DWORD error = GetLastError(); The error code is 1814 which is resource file not found. Elizabeth
-
I tried openning a bitmap file, but still getting a NULl return. Here is the updated code: CString file_name = "c:\\gis\\aspjpeg\\new_file.bmp"; //line #1 m_hBitmap = (HBITMAP)::LoadBitmap(NULL, file_name); //line #2 DWORD error = GetLastError(); The error code is 1814 which is resource file not found. Elizabeth
ElizabethC wrote: The error code is 1814 which is resource file not found. Of course, because a resource named "c:\\gis\\aspjpeg\\new_file.bmp" does not exist in a module having an instance handle of 0. You need to use a non-NULL instance handle, and the specified bitmap should not contain any path information. I think you need to use
LoadImage()
instead.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
ElizabethC wrote: The error code is 1814 which is resource file not found. Of course, because a resource named "c:\\gis\\aspjpeg\\new_file.bmp" does not exist in a module having an instance handle of 0. You need to use a non-NULL instance handle, and the specified bitmap should not contain any path information. I think you need to use
LoadImage()
instead.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
I have just looked up LoadImage(). It also requires a instance handle. Can you suggest what HINSTANCE should I use in a CDialog class? The picture will be displayed at the picture control which is a CStatic control. Elizabeth
-
I have just looked up LoadImage(). It also requires a instance handle. Can you suggest what HINSTANCE should I use in a CDialog class? The picture will be displayed at the picture control which is a CStatic control. Elizabeth
ElizabethC wrote: It also requires a instance handle. Which can be 0.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
ElizabethC wrote: It also requires a instance handle. Which can be 0.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
I got it working with the bitmap file with the return handle: CString file_name = "c:\\gis\\aspjpeg\\file_new.bmp"; m_hBitmap = (HBITMAP)LoadImage(NULL, file_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DWORD error = GetLastError(); However, it the handle is NULL when loading a JPEG file: CString file_name = "c:\\gis\\aspjpeg\\root.jpeg"; // CString file_name = "c:\\gis\\aspjpeg\\file_new.bmp"; //line #1 m_hBitmap = (HBITMAP)LoadImage(NULL, file_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DWORD error = GetLastError(); Do you know how to load a JPEG file into the picture control? Elizabeth
-
I got it working with the bitmap file with the return handle: CString file_name = "c:\\gis\\aspjpeg\\file_new.bmp"; m_hBitmap = (HBITMAP)LoadImage(NULL, file_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DWORD error = GetLastError(); However, it the handle is NULL when loading a JPEG file: CString file_name = "c:\\gis\\aspjpeg\\root.jpeg"; // CString file_name = "c:\\gis\\aspjpeg\\file_new.bmp"; //line #1 m_hBitmap = (HBITMAP)LoadImage(NULL, file_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DWORD error = GetLastError(); Do you know how to load a JPEG file into the picture control? Elizabeth
ElizabethC wrote: Do you know how to load a JPEG file into the picture control? Use GDIPlus::Bitmap class Use IPicture and ::OleLoadPicture() or OleLoadPicturePath() functions.
[
](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!
-
I got it working with the bitmap file with the return handle: CString file_name = "c:\\gis\\aspjpeg\\file_new.bmp"; m_hBitmap = (HBITMAP)LoadImage(NULL, file_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DWORD error = GetLastError(); However, it the handle is NULL when loading a JPEG file: CString file_name = "c:\\gis\\aspjpeg\\root.jpeg"; // CString file_name = "c:\\gis\\aspjpeg\\file_new.bmp"; //line #1 m_hBitmap = (HBITMAP)LoadImage(NULL, file_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DWORD error = GetLastError(); Do you know how to load a JPEG file into the picture control? Elizabeth
ElizabethC wrote: However, it the handle is NULL when loading a JPEG file: Maybe it's not designed to work with non-BMP images.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?