Drawing in Photon

Hi,

I am trying to draw a series of "T"s and "L"s on the screen. The catch
is that the Ts and Ls have to be tilted either right or left at 45
degree angles from upright. I am not using the Application Builder to
do this (I’d rather write the C code myself), but am using Photon to do
the drawing.

The following code was a test version I was trying to run. I get no
warnings or errors either at compile-time or at run-time. I put in lots
of print statements to try to see where things were getting messed up,
but every print statement is “ok”. However, nothing appears on the
screen.

If any one sees what I’m doing wrong (or alternatively, if anyone knows
of a way to rotate drawings), I’d appreciate the feedback.

Thanks,
Shannon

code:
int display_slide( void *data, pid_t pid, void message, ushort_t size){


/
This routine is called when the app builder main loop is
interrupted by a QNX message (initiated by a call to Send
in another process). Note that this is set up by the call
to PtAppAddInput in register_name. First, display_slide calls
Reply to unblock the sending process. Next it extracts the
message
sent by the Send routine by assigning it to the struct variable
msg. (Note that the routine [in rex] which calls Send must use
the identical variable type [i.e. struct definition.]) In this
case
the message is an unsigned integer which holds an ecode. The
image
files use ecodes as filenames. */

struct msg_s {
int dot_density;
char set_to ;
} *msg;

PhImage_t *foo ;
int worked ;

PhPoint_t p = {100,100} ;
msg = ( struct msg_s ) message;


/
Reply should always be called to unblock the sending process
*/

printf(“received msg. dot_density = %d, set_to = %c\n”,
msg->dot_density, msg->set_to );

Reply( pid, “OK!”, 4);

printf(“replied to msg!\n”);

foo = PxLoadImage (“t1.bmp”, NULL) ;

if (foo == NULL) {
printf (“Didn’t load picture.\n”) ;
}
else {
printf (“Loaded ok.\n”) ;
worked = PgDrawBitmap ( foo->image, 0, &p,
&foo->size, foo->bpl, 0) ;
}

if (worked == 0 ) {
printf (“I think I’m drawing.\n”) ;
}
else {
printf (“Ha, ha. I’m not drawing your picture.\n”) ;
}
PtFlush ();
foo->flags = Ph_RELEASE_IMAGE ;
PhReleaseImage (foo) ;
return( Pt_CONTINUE);

}

Hi Shannon,

Sorry for the late reply…
Since I didn’t see any PgSet*() functions in your code, I included this
little bit from the helpviewer:

“The data pointed to by ptr is one bit per pixel. If the pixel value is 1, the pixel is drawn with the
color set by PgSetTextColor() or PgSetTextDither(). If the pixel value is 0, the pixel is drawn as
transparent unless you’ve set flags to Pg_BACK_FILL. With Pg_BACK_FILL, the pixel is drawn
with the color set by PgSetFillColor() or PgSetFillDither(). The pixels are drawn most significant
bit first.”

So, for a test, try doing:
PgSetTextColor( Pg_WHITE );
PgSetFillColor( Pg_PURPLE );

And see if something comes up.

Good luck,
Rich




Shannon Moore <a-cherian@nwu.edu> wrote:

Hi,

I am trying to draw a series of "T"s and "L"s on the screen. The catch
is that the Ts and Ls have to be tilted either right or left at 45
degree angles from upright. I am not using the Application Builder to
do this (I’d rather write the C code myself), but am using Photon to do
the drawing.

The following code was a test version I was trying to run. I get no
warnings or errors either at compile-time or at run-time. I put in lots
of print statements to try to see where things were getting messed up,
but every print statement is “ok”. However, nothing appears on the
screen.

If any one sees what I’m doing wrong (or alternatively, if anyone knows
of a way to rotate drawings), I’d appreciate the feedback.

Thanks,
Shannon

code:
int display_slide( void *data, pid_t pid, void message, ushort_t size){



/
This routine is called when the app builder main loop is
interrupted by a QNX message (initiated by a call to Send
in another process). Note that this is set up by the call
to PtAppAddInput in register_name. First, display_slide calls
Reply to unblock the sending process. Next it extracts the
message
sent by the Send routine by assigning it to the struct variable
msg. (Note that the routine [in rex] which calls Send must use
the identical variable type [i.e. struct definition.]) In this
case
the message is an unsigned integer which holds an ecode. The
image
files use ecodes as filenames. */

struct msg_s {
int dot_density;
char set_to ;
} *msg;

PhImage_t *foo ;
int worked ;

PhPoint_t p = {100,100} ;
msg = ( struct msg_s ) message;



/
Reply should always be called to unblock the sending process
*/

printf(“received msg. dot_density = %d, set_to = %c\n”,
msg->dot_density, msg->set_to );

Reply( pid, “OK!”, 4);

printf(“replied to msg!\n”);

foo = PxLoadImage (“t1.bmp”, NULL) ;

if (foo == NULL) {
printf (“Didn’t load picture.\n”) ;
}
else {
printf (“Loaded ok.\n”) ;
worked = PgDrawBitmap ( foo->image, 0, &p,
&foo->size, foo->bpl, 0) ;
}

if (worked == 0 ) {
printf (“I think I’m drawing.\n”) ;
}
else {
printf (“Ha, ha. I’m not drawing your picture.\n”) ;
}
PtFlush ();
foo->flags = Ph_RELEASE_IMAGE ;
PhReleaseImage (foo) ;
return( Pt_CONTINUE);

}