Yes, that looks about right.
--
Mats
Printable View
Yes, that looks about right.
--
Mats
This is far from guaranteed. Traditionally, Windows draws in "BGR" at the hardware level - it may well represent the image as RGB in user-mode, but once it gets to the driver it will be BGR. [Don't ask me where this comes from - but the hardware I worked on had a bit to say "RGB" or "BGR" when you configure the chip - and it looks "real funny" if you get it wrong].
There's obviously no importance to the order of the colours if we are inverting them - all colours are treated equally. If we were to do things like colour adjustment, we obviously need to understand which colour is which.
--
Mats
quick question, i cant really understand the difference between these 2, they sound the same:
// This routine will put the image pixel data into the supplied matrix
// from top left to bottom right. You must ensure that enough space is
// available.
void ep100_lib_get_data(int data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]);
// This routine will set the image pixel data from the supplied matrix
// from top left to bottom right. You must ensure that enough space is
// available.
void ep100_lib_set_data(int data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]);
ok iv done some work, hopefully iv understood it, so could someone have a look through this pseudocode and advice further(it has left out somethings):
Code:// Invert the image (1 = first argument after a.out)
IF argv[1] = -i THEN
INTEGER data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]
ep100_lib_get_data(data)
ep100_lib_print_data(data)
FUNCTION invert_image(data)
ep100_lib_set_data(data) // Display original image
SLEEP 5 // Pauses program for 5 seconds
ep100_lib_display_image(); // Display inverted image
Code:ALGORITHM invert_image
INTEGER FUNCTION invert_image(INTEGER data[EP100_LIB_MAX_X] [EP100_LIB_MAX_Y])
FOR X 1 to EP100_LIB_MAX_X DO
FOR Y 1 to EP100_LIB_MAX_Y DO
INTEGER data[EP100_LIB_MAX_X] [EP100_LIB_MAX_Y]
red ((data[X][Y]>>16)&0xff)
blue ((data[X][Y]>>8)&0xff)
green ((data[X][Y])&0xff)
data.red 255 – data.red
data.blue 255 - data.blue
data.green 255 - data.green
RETURN
ENDFOR
ENDFOR
END ALGORITHM
THANKS
Like I said in a different post, you probably want to use the image's actual dimensions, as if you have a 100 x 100 pixel image, and your Max X/Y values are 1000, you'll process 990000 pixels out of a million worht of "emptyness", which is a bit of a waste, don't you think.
--
Mats
that ep100_lib_max x etc is defined as 1024
in the assignment it didnt say we get the dimensions from user, we just have to use CLA where a.out -i image.jpeg
-1 = invert
but otherwise does it look alright?
> SLEEP 5 // Pauses program for 5 seconds
I don't think you should be using SLEEP, I think I read it's not portable/ resource heavy ?
was posted by you in another thread. You don't think those functions would do exactly what you need to avoid making 99% of the work unnecessarily?Code:// This function returns the width in pixels of the loaded image.
int ep100_lib_get_image_width();
// This function returns the height in pixels of the loaded image.
int ep100_lib_get_image_height();
--
Mats
ohhhh ya k, ill change that, thanks for reminding me!
now its just how to scroll i have to work on :(
Not to mention that it's completely meaningless. Why would you want to make it run slower than it can? [it won't be INSTANT anyways - although it shouldn't take more than fractin of a second.
If you want to PAUSE soemthing, then you ask the user to press enter or some such - that way, the pause is the right length for the user to see whatever is happening. Waiting X seconds just gets annoying.
--
Mats
I as thinking about scrolling :
Here for this example
To get it scrolled to this :Code:1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
This being a horizontal scroll I assume I need to work out where there is a "split" line , dump the contents either side of the split line into 2 arrays , and then rejoin the arrays , swapping their order . Would this be a good way to do it ?Code:4 5 1 2 3
4 5 1 2 3
4 5 1 2 3
You could do that. Or you could just copy everything into a new data-set and copy it with "offset". The latter may be easier.
--
Mats