

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
5 messages in net.java.dev.jna.users[jna-users] retrieving byte array | From | Sent On | Attachments |
|---|---|---|
| Schneider Jann | Apr 28, 2009 2:04 am | |
| Timothy Wall | Apr 28, 2009 4:08 am | |
| Schneider Jann | Apr 28, 2009 4:22 am | |
| Timothy Wall | Apr 28, 2009 4:46 am | |
| Schneider Jann | Apr 28, 2009 5:33 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [jna-users] retrieving byte array | Actions... |
|---|---|---|
| From: | Schneider Jann (j.sc...@ssi-schaefer-noell.com) | |
| Date: | Apr 28, 2009 2:04:33 am | |
| List: | net.java.dev.jna.users | |
Hi all,
i have this method exported in my dll which writes a bitmap down to disk. But
now i want to avoid writing to disk and instead give back an byte array with
this bitmap to improove performance.
but i don't really see, how i could handle this.. So here comes the method from
C++:
BITMAPINFOHEADER bmpInfoHeader = {0}; // Set the size bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER); // Bit count bmpInfoHeader.biBitCount = wBitsPerPixel; // Use all colors bmpInfoHeader.biClrImportant = 0; // Use as many colors according to bits per pixel bmpInfoHeader.biClrUsed = 0; // Store as un Compressed bmpInfoHeader.biCompression = BI_RGB; // Set the height in pixels bmpInfoHeader.biHeight = lHeight; // Width of the Image in pixels bmpInfoHeader.biWidth = lWidth; // Default number of planes bmpInfoHeader.biPlanes = 1; // Calculate the image size in bytes bmpInfoHeader.biSizeImage = lWidth* lHeight * (wBitsPerPixel/8);
BITMAPFILEHEADER Bfh = {0}; // This value should be values of BM letters i.e 0×4D42 // 0×4D = M 0×42 = B storing in reverse order to match with endian Bfh.bfType = 0x4D42; /* or Bfh.bfType = 'B'+('M' << 8); // <<8 used to shift 'M' to end */ // Offset to the RGBQUAD Bfh.bfOffBits = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); // Total size of image including size of headers Bfh.bfSize = Bfh.bfOffBits + bmpInfoHeader.biSizeImage; // Create the file in disk to write HANDLE hFile = CreateFile("Image001.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(!hFile ) { cerr << "Unable to save image to file " << endl; ... return; }
DWORD dwWritten = 0;
// Write the File header
WriteFile(hFile, &Bfh, sizeof(Bfh), &dwWritten, NULL);
// Write the bitmap info header
WriteFile( hFile, &bmpInfoHeader, sizeof(bmpInfoHeader), &dwWritten, NULL );
// Write the RGB Data
WriteFile( hFile, pBitmapBits, bmpInfoHeader.biSizeImage, &dwWritten, NULL
);
// Close the file handle
CloseHandle( hFile );
Any suggestions?
Thanks in advance.
Regards JannJimm
Mit freundlichen Grüßen / Kind regards
Jann Schneider
IT - Development
SSI Schäfer Noell GmbH i_Park Klingholz 18/19 D-97232 Giebelstadt
phone +49 / (0) 9334 / 979 - 192 fax +49 / (0) 9334 / 979 - 100 eMail j.sc...@ssi-schaefer-noell.com Internet www.ssi-schaefer-noell.com
SSI Schäfer Noell GmbH, Sitz: Giebelstadt, Registergericht: Amtsgericht Würzburg HRB 6936, Geschäftsführung: Gerhard Schäfer, Rudolf Keller, Harrie Swinkels
SSI Schäfer Noell GmbH, Registered office: Giebelstadt, Incorporated in Würzburg: Commercial Register 6936, Managing directors: Gerhard Schäfer, Rudolf Keller, Harrie Swinkels







