alignment

difference in speed between char and integer arrays?

Hello all, currently I'm dealing with a video processing software in which the picture data (8bit signed and unsigned) is stored in arrays of 16-aligned integers allocated as __declspec(align(16)) int *pData = (__declspec(align(16)) int *)_mm_malloc(width*height*sizeof(int),16); Generally, wouldn't it enable faster reading and writing...

Binary Database Aligned or Packed

Is there a way to see, via hex editor or otherwise, if data in a binary file is aligned or packed, specifically for an HPUX system? ...

What is the easiest way to align the Z axis with a vector?

Given a point such as (0, 0, 0) and a vector like (x, y, z). What is the easiest way to align the negative Z-axis centered at (0, 0, 0) to point in the direction of this vector? Examples using OpenGL would be welcome, but not neccessary. ...

What is the Performance, Safety, and Alignment of a Data member hidden in an embedded char array in a C++ Class?

I have seen a codebase recently that I fear is violating alignment constraints. I've scrubbed it to produce a minimal example, given below. Briefly, the players are: Pool. This is a class which allocates memory efficiently, for some definition of 'efficient'. Pool is guaranteed to return a chunk of memory that is aligned for the reques...

How can you align a canvas background in WPF?

I have set a canvas' background to an image of a company logo. I would like for this image to be aligned to the bottom right corner of the canvas. Is it possible to do this, or would it require for the image to be added into the canvas as a child? That would not work with this program as all children of the canvas are handled different...

CSS way to horizontally align table

I want to show a table of fixed width at the center of browser window. Now I use <table width="200" align="center"> But Visual Studio 2008 gives warning on this line: Attribute 'align' is considered outdated. A newer construct is recommended. What CSS style should I apply to the table to obtain the same layout? ...

Tab spaced data to padded columns

Looking for a column formatting script, I have a feeling this could be a one line awk. Ideally, a small shell script is all I am after. The data is tab separated, each cell in each row is of variable length, and of course, may have spaces in it. So we have something like this dasj dhsahdwe dhasdhajks ewqhehwq dsajkdhas e dward da...

Background image in "ul" centered... but I'd like it at the top

On this page (http://www.bonniesphere.com/blog/elsewhere/) the "li" items have an image instead of a bullet. But the image is centered vertically, and in multi-line entries it doesn't look good. Can anyone tell me if there is something in the CSS that should be changed? Here's the relative code: .entry ul {list-style-type:none;} .entry...

How to automatically align python variable assignment lines in vim

I would like to automatically align lines of python variable assignments in vim. For example I would like to change this: a = 1 banana = 2 into this a = 1 banana = 2 automatically in vim. Is there a way to do this? ...

Determining the alignment of C/C++ structures in relation to its members

Can the alignment of a structure type be found if the alignments of the structure members are known? Eg. for: struct S { a_t a; b_t b; c_t c[]; }; is the alignment of S = max(alignment_of(a), alignment_of(b), alignment_of(c))? Searching the internet I found that "for structured types the largest alignment requirement of any of i...

unaligned memory accesses

I'm working on an embedded device that does not support unaligned memory accesses. For a video decoder I have to process pixels (one byte per pixel) in 8x8 pixel blocks. The device has some SIMD processing capabilities that allow me to work on 4 bytes in parallel. The problem is, that the 8x8 pixel blocks aren't guaranteed to start on...

Purpose of memory alignment

Admittedly I don't get it. Say you have a memory with a memory word of length of 1 byte. Why can't you access a 4 byte long variable in a single memory access on an unaligned address(i.e. not divisible by 4), as it's the case with aligned addresses? ...

Aligning image and text vertically within TD element

<td> <img src="http://blog.garethjmsaunders.co.uk/wp-content/feed-icon-16x16.gif"/&gt; My feed </td> This is how it looks like: My feed The icon and the text is misalligned vertically. The icon is on the top of the table cell, the text is on the bottom. Both the text and the icon occupy 16 pixel but the cell still eats up 19. H...

What tranformations are used by little-endian systems to convert data to network order?

What are the underlying transformations that are necessary to convert data in a little-endian system into network byte order? For 2 byte and 4 byte data there are well-known functions (such as htons, ntohl, etc.) to encapsulate the changes, what happens for strings of 1 byte data (if anything)? Also, Wikipedia implies that little-endian...

CSS alignment of text of HTML INPUT radio element.

I have an input[type="radio"] element inside a block container of fixed width. The supporting text for the input element does not fit in a single line, and falls over to two or more lines. For example: <div class="leftBlock"> <input type="radio" name="foo" value="bar" id="option" /> This is a rather long supporting text that doe...

How to vertically align Paragraphs within a Table using Reportlab?

I'm using Reportlab to generate report cards. The report cards are basically one big Table object. Some of the content in the table cells needs to wrap, specifically titles and comments, and I also need to bold certain elements. To accomplish both the wrapping and ability to bold, I'm using Paragraph objects within the Table. My tabl...

Is there any guarantee of alignment of address return by C++'s new operation?

Hi, Most of experienced programmer knows data alignment is important for program's performance. I have seen some programmer wrote program that allocate bigger size of buffer than they need, and use the aligned pointer as begin. I am wondering should I do that in my program, I have no idea is there any guarantee of alignment of address r...

CSS same-line aligning

Is there an elegant way to align 3 elements left, center, and right on the same line? Right now I'm using 3 <div>'s all with width:33%;float:left; and it's not working too well. ...

Mis-aligned pointers on x86

Can someone provide an example were casting a pointer from one type to another fails due to mis-alignment? In the comments to this answer, bothie states that doing something like char * foo = ...; int bar = *(int *)foo; might lead to errors even on x86 if alignment-checking is enabled. I tried to produce an error condition after set...

Character Alignment with an OwnerDraw ListView in C#

I'm trying to implement a .NET control that functions like the Firefox Awesome Bar. To that end, I'm trying to bold and underline searched for characters inside of search results displayed in a ListView. I've set up OwnerDraw and I'm using Graphics.MeasureCharacterRanges to figure out how big the characters are. The problem I'm having...