×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SVGA - how to read pixel color?? ATI adapter

SVGA - how to read pixel color?? ATI adapter

SVGA - how to read pixel color?? ATI adapter

(OP)
i'm doing a software (17,000 lines untill now) that works in SVGA 800x600 256 colors mode (using banks) and i need to save the background and than drawing it back again, i made the algorithem for saving the background (if you want it notify me) anyway, my problem is this:

i need to read a pixel color from the screen at specified coord (x,y) to do so i build this function (2 ways):

(1)
int get_pixel(int x, int y)
/* Function reads a pixel from the screen   *
 * from coordinates x,y (the offset)        *
 * and returning the pixel color            */
{
  int color;
  int bits_per_pixel = 8; // 2^8 = 256 colors
  long offset = ((long)y*SCREEN_WIDTH+(long)x)*(bits_per_pixel>>3);
  setbank(offset>>16);
  color=(*(video_buffer+offset))*(bits_per_pixel>>3);
  return(color);
}


(2)
int get_pixel(int x, int y)
{
  asm {
      mov ah, 0dh
      mov bh, 0
      mov cx, x
      mov dx, y
      int 10h
  }

  return(_AL);
}


in both ways the function works but only at non-ati adapters, if i'm calling the function at a computer that has an ati adapter i'm getting colors only from the first segment at screen.

i have checked these function at home (i've got voodoo) and it works.

if you know other ways to read a pixel color please tell me or if you have any suggestion for how to solve this problem please replay.

thanks from advanced,
Guy Zana

RE: SVGA - how to read pixel color?? ATI adapter

Do you use a graphics driver?
If not then you can only get to this mode (800x600) using VBE instructions (AX=4F__h; INT 10h) and standard 10h video instructions may not be supported in these modes.
If you use a driver, then use the driver's getpixel command.

I use the VBE and Pascal + Assembly and I have no problems with ATI adapters.

Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
http://www.geocities.com/thevhbcompany/
Don't worry what people think about you. They're too busy wondering what you think about them.

RE: SVGA - how to read pixel color?? ATI adapter

(OP)
anyone knows a good svga programming site with c for Dos?

RE: SVGA - how to read pixel color?? ATI adapter

I really suggest avoiding BIOS interrupts.  I would rather implement multiple versions of the getpixel routine which interface direct to hardware.  Then, at card detection time, bind getpixel() to the proper routine (just leave a dummy jmp far at the getpixel procedure).

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

RE: SVGA - how to read pixel color?? ATI adapter

(OP)
Thanks bertv100 and thanks amkG,
i don't know what you meant could you give an example

bye

RE: SVGA - how to read pixel color?? ATI adapter

getpixel proc
    JMP far ptr getpixel
getpixel endp

getpixelATI proc
;hardware-specific get pixel
.
.
.
.
getpixelATI endp

getpixelS3 proc
.
.
.
.
getpixelS3 endp

;other getpixels for other adapters
.
.
.
.

initgraphicsystem proc
    Call DetectGraphicsAdapter
    cmp Adapter,ATI
    jne notATI
    mov si,addr getpixelATI
    jmp loadgetpixel
notATI:
    cmp Adapter,S3
    jne notS3
    mov si,addr getpixelS3
    jmp loadgetpixel
notS3:
.
.
.
.
loadgetpixel:
    mov getpixel+1,si
    push cs
    pop getpixel+3
;other inits
.
.
.

    ret
initgraphicsystem endp


Of course, you would probably be making several hardware specific routines, one routine each for one of the things you want to do (switch banks for example, or get and write pixels, or even draw lines so that you have more efficiency).  To do that you can use procedure tables instead of just routines, have procedure pointers loaded into tables, separated by adapter, and at init time just load the procedure pointers into the main procedure table which is referenced by the rest of the program.

Note that this is largely an ASM technique although you can implement this in C (with some difficulty, because you need to say it in a way that C understands).

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close