Mobile Apps - Converting stream to hBitmap
Asked By Afikim via PocketPCJunkies.com
06-Nov-09 01:41 PM
Hello
I need to know how to convert a jpeg stream to bitmap. It will be used for
IpCam.
The picturebox that displays the jpeg is loading only from bitmaps image.
fromhbitmap.
Thanks
Eli
--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-programming/200911/1
CreateBitmapFromImage
(1)
CreateImageFromFile
(1)
BitmapData.scan0
(1)
StretchDIBits
(1)
IImagingFactory
(1)
IBitmapImage
(1)
APIs
(1)
BitmapData
(1)
Vinoth replied to Afikim via PocketPCJunkies.com
if it is the JPEG image, you can use imaging APIs.
Note:
Imaging APIs are COM objects.
Following Procedure helps you in creating the Bitmap.
1) call IImagingFactory::CreateImageFromFile () to get the IImage interface
from the jpg file.
2) pass the IImage to
IImagingFactory::IImagingFactory::CreateBitmapFromImage () to get the
IBitmapImage inteface.
3) Call the IBitmapImage::LockBits() to get the BitmapData struture.
BitmapData.scan0 is the data
bytes.
4) Create a BITMAPINFO structure and pass this with BitmapData.scan0 to
StretchDIBits() to draw on screen.
Hope this will give you an idea to draw the JPEG image.
--
vinoth.R
Technical Lead
e-consystems India Pvt Ltd
www.e-consystems.com
My Articles & blogs:
http://www.windowsfordevices.com/articles/AT8185724467.html
http://www.e-consystems.com/portingwincepxa255.asp
http://e-consystems.com/gprsconnectivity.asp
http://vinoth-vinothblog.blogspot.com
http://e-consystems.com/blog

for your replies. Pat O WindowsCE Embedded Discussions Visual Studio 2005 (1) Visual Studio (1) CreateBitmapFromImage (1) CreateImageFromFile (1) ImageLockModeRead (1) GUIDs (1) InterpolationHintDefault (1) LockedBitmapData.Scan0 (1) I forgot to ask my NULL) { IImage * pImage = NULL; IBitmapImage * pBitmap = NULL; LPCTSTR tszFileName = TEXT(" / Logo.bmp"); HRESULT hr = g_pImagingFactory-> CreateImageFromFile(tszFileName, &pImage); if(FAILED(hr)) { / / TODO ?? info(TEXT("Failed to load image from file %s s"), tszFileName, _com_error(hr).ErrorMessage()); return 0; } else { SIZE size; pImage-> GetPhysicalDimension(&size); hr = g_pImagingFactory-> CreateBitmapFromImage(pImage, size.cx, size.cy, PixelFormat16bppRGB565, InterpolationHintDefault, &pBitmap); if(FAILED(hr)) { / / TODO ?? info(TEXT("Failed TODO How should I cleanup the image? } } EndPaint(hWnd, &ps); break; It fails on the CreateImageFromFile call. The Visual Studio Debugger tells me the HRESULT is hr = -2147024894 {The system cannot
suggestion which indicate how to rotate bitmap step by step as follows: CoInitialize CoCreate CLSID_ImagingFactory CreateImageFromFile which returns you an IImage interface Query the IImage interface for IBasicBitmapOps interface use the ImageInfo *info = NULL; IBitmapImage *rotebitmap = NULL; IBasicBitmapOps *oper = NULL; NULL, CLSCTX_INPROC_SERVER, IID_IImagingFactory, (void * *)&pFactory); pFactory-> CreateImageFromFile(L" \ jupiter.jpg", &pImage); pFactory-> CreateBitmapFromImage(pImage, 0, 0, PixelFormatDontCare, InterpolationHintDefault, &rotebitmap); pImage-> QueryInterface(IID_IBasicBitmapOps, (void * *) &oper); oper-> Rotate(180.0 hdc, &test , NULL); WindowsCE Platform Builder Discussions IImage (1) IBasicBitmapOps (1) InterpolationHintDefault (1) PImage (1) CreateImageFromFile (1) PFactory (1) IBitmapImage (1) CreateBitmapFromImage (1) means that you would like to get a pointer to an interface that is
into a HBITMAP? thx, eric. WindowsCE Embedded Discussions Windows Mobile 5.0 (1) SHLoadImageFile (1) CreateImageFromFile (1) CoCreateInstance (1) IImagingFactory (1) CoInitializeEx (1) ReleaseDC (1) GetDC (1) Hi, Depending upon platform NULL, CLSCTX_INPROC_SERVER, / *IID_IImagingFactory* / _ _uuidof (IImagingFactory) , (void* *)&pFactory); if (hr = = S_OK) { IImage *pImage = NULL; hr = pFactory-> CreateImageFromFile(L" \ ThePath \ TheImage.png", &pImage); if (hr = = S_OK) { CDC *pCdc = GetDC(); RECT rect; rect.top