G11 porting - page 16 - DryOS Development - CHDK Forum  

G11 porting

  • 530 Replies
  • 245906 Views
Re: G11 porting
« Reply #150 on: 03 / January / 2010, 09:33:16 »
Advertisements
I would not spend any time on the splashscreen, you need to know how the bitmap buffer relates to the physical screen first.

You do that by drawing a permanent simple geometric shape, such as a square.

Do you know the bitmap buffer dimensions and also the size of the physical screen ?

*

Offline ERR99

  • ****
  • 339
Re: G11 porting
« Reply #151 on: 03 / January / 2010, 15:47:43 »
Do you know the bitmap buffer dimensions and also the size of the physical screen ?
No exactly. But i think that the physical screen size is two times the size of the G9 display (because subpixel value is doubled between G9 & G11). So i assume that the physical display resolution is now 640x480.
I replaced the splash screen now with your draw rectangle code, but your code snippet was not complete. So is my "interpretation" of the code correct?:
Code: [Select]
void DrawRectangle(void)
{
int offset=80*screen_buffer_width;
static unsigned char* imgbuf = 0;
long ss = vid_get_bitmap_screen_width()* vid_get_bitmap_screen_height();
unsigned char* scr_buf = vid_get_bitmap_fb();
int x,y;
if (!imgbuf)
{
imgbuf = malloc(ss);
}
if(imgbuf)
{
memset(imgbuf,COLOR_TRANSPARENT,ss);                                  // clear screen
memcpy(scr_buf,imgbuf,ss);
memcpy(scr_buf+ss, imgbuf, ss);                                       // update second buffer
for(x=0;x<120;x++)
{
 for(y=0;y<80;y++)                                                    // for each row
 {
  imgbuf[(120*2)+2*x+(y*screen_buffer_width)+offset]=COLOR_RED;     //  from x=120 to x=240
  imgbuf[(120*2)+2*x+(y*screen_buffer_width)+offset+1]=COLOR_RED;
 }
}
 memcpy(scr_buf,imgbuf,ss);
 memcpy(scr_buf+ss,imgbuf,ss);// update second buffer
return 1;
}
return 0;
}

With this code, and the values 640 and 480 for width and height, i get the attached picture on the G11 display.

Re: G11 porting
« Reply #152 on: 03 / January / 2010, 16:07:18 »
I will look at that shortly.

For a pixel at x,y the location in the bitmap buffer is y*buffer_width + x  or maybe y*buffer_width + 2*x.
In the latter case, you normally have to draw each pixel twice.
The buffer-width may or may not be greater than the width of the buffer that the Canon firmware renders to the screen.

In other words, just a top-left area of the buffer may be rendered to the screen.


Re: G11 porting
« Reply #153 on: 03 / January / 2010, 16:17:18 »
So, 80*screen_buffer_width should get us 1/3rd the way down a 240 high screen area  .. if the height is 240 and if the buffer width is correct.
That is the 'offset' value.

The start of the first screen buffer must be correct.

If not already allocated, you allocate an amount of memory equal in size to the screen buffer.
If that is allocated OK, you first clear both bitmap buffers  by writing 'transparent' pixels to them.

For the next 80 rows, we draw pixels from x = 120 to x = 240.
That will be 1/3rd the screen if it is 360 wide.
The above code draws each pixel twice, normally for a 720 wide buffer or a wider buffer that uses 720 wide for the screen size.

Anyway, it is not correct for the G11   ;)

Try 360x240 screen and draw each pixel once in the 'x' direction.
« Last Edit: 03 / January / 2010, 16:19:45 by Microfunguy »


Re: G11 porting
« Reply #154 on: 03 / January / 2010, 16:54:07 »
There again, it really could be 640x480.

In which case, set intial offset to 160* screen_buffer_width and draw pixels from 160 to 320.

Pixel x,y at position  640*y + x.

Something like :-

Code: [Select]
void DrawRectangle(void)
{
int offset=160*screen_buffer_width;
static unsigned char* imgbuf = 0;
long ss = vid_get_bitmap_screen_width()* vid_get_bitmap_screen_height();
unsigned char* scr_buf = vid_get_bitmap_fb();
int x,y;
if (!imgbuf)
{
imgbuf = malloc(ss);
}
if(imgbuf)
{
memset(imgbuf,COLOR_TRANSPARENT,ss);                                  // clear screen
memcpy(scr_buf,imgbuf,ss);
memcpy(scr_buf+ss, imgbuf, ss);                                       // update second buffer
for(x=0;x<213;x++)
{
  for(y=0;y<160;y++)                                                    // for each row
  {
   imgbuf[213+x+(y*screen_buffer_width)+offset]=COLOR_RED;     //  from x=213 to x=426
  }
}
  memcpy(scr_buf,imgbuf,ss);
  memcpy(scr_buf+ss,imgbuf,ss);// update second buffer
return 1;
}
return 0;
}
« Last Edit: 03 / January / 2010, 17:11:51 by Microfunguy »

*

Offline ERR99

  • ****
  • 339
Re: G11 porting
« Reply #155 on: 03 / January / 2010, 17:28:24 »
Okay, with display&buffer dimensions 640x480 and your modified DrawRectangle function, i get this picture:

*

Offline reyalp

  • ******
  • 14118
Re: G11 porting
« Reply #156 on: 03 / January / 2010, 17:39:59 »
You may find it useful dump the entire bitmap buffer (or actually some arbitrary amount of memory starting at the bitmap address, since you don't know the actual resolution) to a file, and then examine it on the PC.

I wouldn't expect it to be 640x480, or necessarily the same as the G9 or any other particular camera. Note that in the G9, both the bitmap buffer and bitmap screen are 360x240 (edit: at least according to lib.c, I assume someone would have complained by now if it were wrong). The bitmap dimensions don't appear have any particular relationship to canons specs for LCD resolution, and the *buffer* dimensions are not necessarily the same as the bitmap resolution.

You might want to look at some of the other cameras with odd layouts, such as the sx200, sd990, tx1 to get some ideas about the different things canon does.

Don't forget what the H stands for.

Re: G11 porting
« Reply #157 on: 03 / January / 2010, 17:40:35 »
OK, to make it less confusing just draw a few pixels (enough to be easily visible) at various co-ordinates that could be the centre of the screen, starting with 320,240.

EDIT:

Draw a small group of pixels at various positions on the first row until they are in the middle of the screen area.

Then repeat with an offset of buffer width.

If the buffer width is correct the pixels will be directly underneath the first ones.

« Last Edit: 03 / January / 2010, 17:50:01 by Microfunguy »


*

Offline ERR99

  • ****
  • 339
Re: G11 porting
« Reply #158 on: 03 / January / 2010, 18:34:23 »
I think i made a little progress now. With a screen buffer dimension of 960x240, the pixels are underneath.
I used this function to draw 10 pixels (with one pixel space for better visibility):
Code: [Select]
void DrawLine(void)
{
int offset=0*screen_buffer_width;
static unsigned char* imgbuf = 0;
long ss = vid_get_bitmap_screen_width()* vid_get_bitmap_screen_height();
unsigned char* scr_buf = vid_get_bitmap_fb();
int x,y;
if (!imgbuf)
{
imgbuf = malloc(ss);
}
if(imgbuf)
{
memset(imgbuf,COLOR_TRANSPARENT,ss);                                  // clear screen
memcpy(scr_buf,imgbuf,ss);
memcpy(scr_buf+ss, imgbuf, ss);                                       // update second buffer
x = screen_buffer_width/2;
for (y=(240/2); y<(240/2)+20;y+=2) 
{
imgbuf[x+(y*screen_buffer_width)]=COLOR_BLUE; 
}
  memcpy(scr_buf,imgbuf,ss);
  memcpy(scr_buf+ss,imgbuf,ss);// update second buffer
return 1;
}
return 0;
}

So i think i have got the screen_buffer_width now. But something is strange:
The y position looks ok, it is one the middle of the display as expected. But the x position is not centred, i start drawing at 960/2, but the line is drawn in the right 1/3rd of the screen.

Re: G11 porting
« Reply #159 on: 03 / January / 2010, 18:37:33 »
Am I missing something, the 'x' position looks centred ?

EDIT:

My CRT monitor is faulty and too dark.

I drag it onto the TFT and I can see what you mean.

EDIT:
So, the bitmap area used by the Canon firmware is the 720x240 left-side  of the 960x240  buffer.

Note that in draw_init() in gui_draw.c :-

    screen_width = vid_get_bitmap_width();
    screen_height  = vid_get_bitmap_height();

which is not the same as bitmap buffer width (apparently) for the G11.
« Last Edit: 03 / January / 2010, 19:01:37 by Microfunguy »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal