how can i find total number of pixels in 24bit rgb color model - multimedia

24 bits RGB color model with 2048 pixels in width and 1536 pixels in
height has a total of 3.1 megapixels is correct if that so how to get this answer. I am totally new to multimedia section

Total Pixels = [Pixel width * Pixel height * color depth * #frames per seconds]
= [2048 * 1536 * (24/8)]/1024 * 1024
= 9 Megapixel

Related

Calculate aspect ratio of a hexagonal playing field

I'm rendering a grid of flat-topped hex tiles onto a HTML5 canvas. Placement and picking work flawlessly. At all times, the whole grid should be visible.
For this I calculate the minimum rectangle containing all hexagons completely and use its height and width to calculate the canvas size (letterboxed). To calculate the size I use the same coordinates I use to pick and layout the tiles and calculate:
tile_width = 2 // 2 * distance center-corner
tile_height = 1.7320508075688772 // sqrt(3) * distance center-corner
horiz_dist = 1.5 // 3/4 * tile_width
width = 1/4 * tile_width + number_x_tiles * horiz_dist
height = 1/2 * tile_height + number_y_tiles * tile_h
aspect = width/height
However, the displayed tiles are distorted, they are stretched in x-direction. Is there anything wrong with my formula? The measurements were derived as the fantastic redblob games resource describes it.
I'm pretty sure the function that applies x- and y-scaling depending on the aspect ratio works fine, as orthogonal maps look exactly as they should.
From your post, you seem to want a flat-topped grid. Given the information from your link,
tile_width = size * 2 = 2
tile_height = sqrt(3) * size = sqrt(3)/2 * tile_width = sqrt(3)
horiz_dist = (tile_width + size) / 2 = tile_width * 3/4 = 1.5
where size = 1 is the length of the edge of the hexagon.
Defining number_x_tiles as being the number of odd columns and even columns in the grid, your computation for the grid width is correct:
width = tile_width + (number_x_tiles - 1) * horiz_dist
= tile_width + (number_x_tiles - 1) * tile_width * 3/4
= tile_width - tile_width * 3/4 + number_x_tiles * tile_width * 3/4
= 1/4 * tile_width + number_x_tiles * horiz_dist
So the problem is in computing the grid height. Your formula
height = 1/2 * tile_height + number_y_tiles * tile_height
is correct when the number of rows of hexagons in an odd column is the same as an even column (by convention say the first column is the even column and the second column is odd). If not, then you need to determine whether there are more rows of hexagons in the odd column versus even column. Therefore, the logic should be:
if (num_rows_in_odd_column == num_rows_in_even_column)
height = 1/2 * tile_height + number_y_tiles * tile_height
else
number_y_tiles = max(num_rows_in_odd_column, num_rows_in_even_column)
height = number_y_tiles * tile_height
Hope this helps.

How accurate is using millimeters in CSS?

I'm trying to use mm in CSS as opposed to the standard px.
first is this even possible?
if so, can i use it like this:
#div{
width:200mm;
height:100mm;
}
I did try to convert the millimeters to pixels so I can use the pixels value but every converter returns a different value which is strange. even Photoshop converts it and gives me a different value.
Could someone please advise on this issue?
The CSS Values and Units Module Level 3 defines the mm unit as 1/10th of 1cm. It also defines the cm unit as 96px/2.54.
In CSS, 200mm and 100mm are always equal to the same px value:
For 200mm:
cm = (200mm / 10)
px = cm * (96 / 2.54)
-> 755.91px
For 100mm:
cm = (100mm / 10)
px = cm * (96 / 2.54)
-> 377.95px
(Note that these values are rounded).

Computing target DPI value from specific dimensions

A rather basic maths problem.
I got an image with a specific width and height in pixels:
WIDTH = 3648 px
HEIGHT = 2736 px
In order to compute the target print size in millimeters, given a specific DPI amount (200) i came up with this:
PRINT-WIDTH = IMAGE-WIDTH-PX / 200 * 2.54 * 10;
PRINT-HEIGHT = IMAGE-HEIGHT-PX / 200 * 2.54 * 10;
This works well. In our example it computes
463 x 347 mm
as target print size. Perfect.
However, i now must be able to make changes to the widths and heights in millimeters, and based on the fact that we assume 200 DPI for printing, i must compute the new DPI value.
So for instance, when changing 463 x 347 to 400 x 300 i should somehow be able to calculate how that affects the DPI.
The only possible approach that came to my mind was to compute the difference between the old and the new format as a percentage, and then apply that percentage to the DPI. But the results are incorrect.
How can i compute the DPI value from the new width and height, given the original 200 DPI matching the original format?
NewDPI = 200 * 463 / 400
Or without using DPI 200 at all:
NeededDPI = IMAGE-WIDTH-PX(3648) * 25.4 / PRINT-WIDTH(400)

Scaling a window while keeping ratios the same

I have a resizable window, and a graph which consists of 11 lines of different values ranging from 0 to 1000. What is the math I would use to compute this?
I want to have the data ranging from 0 to 1000 be so that it equals 0-1000 pixels on screen. But if I resize my window to say 640 / 480, the graph will adjust only will be less detailed.
This is a simple proportion: if 640 pixels bar represents value of 1000, value of Y will represent 640 * Y / 1000 pixels bar.
You did not specify a programming language.
In HTML you can size anything as %, so you calculate size as % of maximum - i.e. 550 (out of 1000 max) = 55%
If you use % size it will automatically adjust with screen/window size.
If you specify your programming language of choice we may be able to help you more

How to get new rectangle value when x and y axis increase

I have a rectangle say (150, 200, 25,25) and x- axis up to 800 and y-axis upto 650. Now like to increase the value of x and y axis by 100. The rectangle value also increase according to x and y axis.
say my rectangle are in the shaded place. now i increase the x and y axis. the shaded position also increases. the rectangle value also need to increase so it placed in that shaded place as before.
How can i achieve this...
Thanks in advance....
ratio = Convert.ToDouble(new x- axis) / Convert.ToDouble(old x -axis);
rect1.X = Convert.ToInt16((rectangles[c].X) * ratio);
rect1.Y = Convert.ToInt16((rectangles[c].Y * ratio));
rect1.Width = Convert.ToInt16(rectangles[c].Width * ratio);
rect1.Height = Convert.ToInt16(rectangles[c].Height * ratio);
Use a scale factor for each axis>
ScaleFactorX = NewValueAxisX / OldValueAxisX = 900/800 (in your example
NewRectValuesX = OldRectValuesX * ScaleFactorX
the same for Y axis
If your rect was at the top (at 800), now it will be at
NewRectValue = 800 * Scale = 800 * 900/800 = 800 (still at the top)

Resources