24-bit

How to create a bmp file from byte[] in C#

Hello, I have a byte[] array received in TCP Client.The array contains a 24-bit RGB Bitmap file.How to create that bitmap file with given Width ,Height and data? In C++ I use this int WriteBitmapFile(const char *filename, int width, int height, unsigned char *imageData) { FILE *filePtr; // file pointer BITMAPFILEHEA...

How do I make a CMFCToolBar recognize image masks?

I have a CMFCToolBar-derived class and an insance thereof is the member of a CDockablePane-derived class. I looked at the VisualStudioDemo sample to see how it's done and have this so far: int CMyPane::OnCreate(LPCREATESTRUCT lpCreateStruct) { // Removed all "return -1 on error" code for better readability CDockablePane::OnCre...

PHP GD2, Convert resource image to 24-bit BMP

Hi. I need to convert resource image to 24-bit BMP image with GD2. This code creates 32-bit BMP image, but I need 24-bit. Help please. function imagebmp(&$im) { if (!$im) return null; $w = imagesx($im); $h = imagesy($im); $result = ''; if (!imageistruecolor($im)) { $tmp = imagecreatetruecolor($w, $h);...

Why 24 bits registers?

Hi, In my work I deal with different micro-controllers, micro-processors and DSP processors. Many of them have 24-bits registers and counters. I know how to use them, this is not my question. My question is why do they have 24-bits register! why not make it 32 bit? and as I know, it is not a problem of size, because the registers are ...

Padding in 24-bits rgb bitmap

Hi, could somebody explain to me why in 24-bit rgb bitmap file I have to add a padding which size depends on width of image ? What for ? I mean I must add this code to my program (in C): if( read % 4 != 0 ) { read = 4 - (read%4); printf( "Padding: %d bytes\n", read ); fread( pixel, read, 1, inFile ); } ...

C/C++ - Convert 24-bit signed integer to float

I'm programming in C++. I need to convert a 24-bit signed integer (stored in a 3-byte array) to float (normalizing to [-1.0,1.0]). The platform is MSVC++ on x86 (which means the input is little-endian). I tried this: float convert(const unsigned char* src) { int i = src[2]; i = (i << 8) | src[1]; i = (i << 8) | src[0]; ...

Java playback of 24 bit audio is incorrect

I am using the javax sound API to implement a simple console playback program based on http://www.jsresources.org/examples/AudioPlayer.html. Having tested it using a 24 bit ramp file (each sample is the last sample plus 1 over the full 24 bit range) it is evident that something odd is happening during playback. The recorded output is ...

How to convert 24-bit wav to mp3 with Lame using C++

Hello all, I am using the Lame library in a C++ application to encode wav files to mp3 files. It works ok for 16-bit wavs, but now I need to convert some 24-bit wavs and I cannot seem to find the way. In particular, I cannot find a function for setting the "bitwidth" parameter taken as a switch by the lame command line. (The command l...

How to write a 24 bit message after reading from a 4-byte integer on a big endian machine (C)?

I am constructing a message to send a 24-bit number over the network. For little endian machines, the code is (ptr is the pointer to the message buffer): *ptr++ = (num >> 16) & 0xFF; *ptr++ = (num >> 8) & 0xFF; *ptr++ = (num) & 0xFF; (So if num0, num1, num2 and num3 are the individual bytes making up num, the message would be e...

Reducing sample bit-depth by truncating

I have to reduce the bit-depth of a digital audio signal from 24 to 16 bit. Taking only the 16 most significant bits (i.e. truncating) of each sample is equivalent to doing a proportional calculation (out = in * 0xFFFF / 0xFFFFFF)? ...