Click here to Skip to main content
15,901,426 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to update xml attributes using console application Pin
sharanu10-Jan-08 0:53
sharanu10-Jan-08 0:53 
AnswerRe: How to update xml attributes using console application Pin
David Crow10-Jan-08 2:17
David Crow10-Jan-08 2:17 
AnswerRe: How to update xml attributes using console application Pin
CPallini10-Jan-08 2:37
mveCPallini10-Jan-08 2:37 
GeneralScanline problem in bitmap Pin
trioum10-Jan-08 0:39
trioum10-Jan-08 0:39 
GeneralRe: Scanline problem in bitmap Pin
CPallini10-Jan-08 2:42
mveCPallini10-Jan-08 2:42 
QuestionRe: Scanline problem in bitmap Pin
Mark Salsbery10-Jan-08 7:13
Mark Salsbery10-Jan-08 7:13 
GeneralRe: Scanline problem in bitmap Pin
trioum10-Jan-08 17:58
trioum10-Jan-08 17:58 
GeneralRe: Scanline problem in bitmap Pin
Mark Salsbery11-Jan-08 12:58
Mark Salsbery11-Jan-08 12:58 
For BMP files, here's a simple method...
HBITMAP hBitmap = (HBITMAP)::LoadImage(NULL, _T("C:\\Some.bmp"), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);

if (hBitmap)
{
   // Get information about the loaded DIBSection

   DIBSECTION DibSection;
   ::GetObject(hBitmap, sizeof(DibSection), &DibSection);


   // Calculate a pointer to the pixel data for a given scanline

   LONG scanline = ...;
   BYTE *pScanlineBytes;

   if (DibSection.dsBmih.biHeight > 0)
      pScanlineBytes = (BYTE*)DibSection.dsBm.bmBits + (DibSection.dsBm.bmWidthBytes * ((DibSection.dsBm.bmHeight - 1) - scanline));
   else
      pScanlineBytes = (BYTE*)DibSection.dsBm.bmBits + (DibSection.dsBm.bmWidthBytes * scanline);


   // Clean up

   ::DeleteObject(hBitmap);
}

For other file formats, you need to either parse the file yourself and provide any
decompression necessary, or you can use a third-party library. For Win32 in C++
you can use GDI+ to load png, jpeg, tiff, gif, exif, and bmp. If you want to use
GDI like the code above once the image is loaded, then the GDI+ Bitmap::GetHBITMAP()
method will give you a DIBSection handle (HBITMAP) from a GDI+ Bitmap object.

If you can use C++, I would recommend using the ATL CImage class. It will handle all the
image types that GDI+ handles, and has simple methods for accessing scanlines as I've
demonstrated above.

Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

General[Message Deleted] Pin
trioum11-Jan-08 18:42
trioum11-Jan-08 18:42 
GeneralRe: Scanline problem in bitmap Pin
Mark Salsbery12-Jan-08 7:32
Mark Salsbery12-Jan-08 7:32 
GeneralLockWindowUpdate & Vista Pin
baerten9-Jan-08 23:54
baerten9-Jan-08 23:54 
GeneralUsing handle between two process Pin
ashtwin9-Jan-08 23:29
ashtwin9-Jan-08 23:29 
GeneralRe: Using handle between two process Pin
Maxwell Chen9-Jan-08 23:37
Maxwell Chen9-Jan-08 23:37 
GeneralRe: Using handle between two process Pin
CPallini9-Jan-08 23:47
mveCPallini9-Jan-08 23:47 
GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 0:19
Maxwell Chen10-Jan-08 0:19 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 0:36
mveCPallini10-Jan-08 0:36 
GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 3:48
Maxwell Chen10-Jan-08 3:48 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 3:58
mveCPallini10-Jan-08 3:58 
GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 4:08
Maxwell Chen10-Jan-08 4:08 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 4:35
mveCPallini10-Jan-08 4:35 
GeneralRe: Using handle between two process [modified] Pin
CPallini10-Jan-08 4:18
mveCPallini10-Jan-08 4:18 
GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 4:36
Maxwell Chen10-Jan-08 4:36 
GeneralRe: Using handle between two process Pin
Mark Salsbery10-Jan-08 7:19
Mark Salsbery10-Jan-08 7:19 
GeneralRe: Using handle between two process Pin
Hamid_RT9-Jan-08 23:47
Hamid_RT9-Jan-08 23:47 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 0:22
mveCPallini10-Jan-08 0:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.