c# - Why must "stride" in the System.Drawing.Bitmap constructor be a multiple of 4? -
I am writing an application for which I should take a proprietary bitmap format (an MVTEEC HLMJ) and convert it to a system Drafting in C # Bitmap
Only one of the proprietary functions given to help me include writing to file in addition to the use of the "get pointer" function.
This function is very good, it gives me a hint for pixel data, width, height and type of image.
My problem is that when I make my system. Drawing Constructor using bitmap:
New system. Drawing Bitmap (width, height, stretch, format, scan)
I need to specify "stride" is a valuable value of 4. This can be a problem because I'm sure what type of bitmap will hit my function I believe I end with a bitmap of 111x111 pixels, I have no way to run this function except for adding a bogus column to my image or subtracting 3 columns.
Is there any way I can sneak around the boundaries?
It goes back to initial CPU designs the fastest way to crack through bitmap bits When starting from the beginning of a scan line, they are read by 32-bit time, this works best when the first byte of the scan line is attached to a 32-bit address limit. In other words, one address is a bigger of 4. In the initial CPU, the first byte will get the cost of additional CPU cycles to have 32-bit values for 32-bit values by reading two 32-bit words with RAM and rotating the bytes. Be sure to start each scan line starting at a coalition address (if it is automatically valued at width 4).
This is no longer a real concern on the actual CPU, now the alignment in the cache line border is more important; Despite this, the majority of the surroundings are surrounded for apppamped reasons.
BTW, you can easily calculate the format and width with its width:
int bitsPerPixel = ((int format) & 0xff00) & gt; ; & Gt; 8; Int bytespariccel = (bitspixel + 7) / 8; Intra Strand = 4 * ((width * byte pepperix + 3) / 4);
Comments
Post a Comment