v_bit_image

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Yod801
Retro freak
Retro freak
Posts: 13
Joined: Mon May 15, 2017 5:50 pm

v_bit_image

Postby Yod801 » Thu Feb 15, 2018 1:23 pm

Hello,

I'm trying to display an image file called CLIP.IMG with the following Pure C code:

Code: Select all

#include <stdio.h>
#include <vdi.h>

int main(void) {
   
   char file[13];
   int handle=0;
   int w_in[11];
   int w_out[57];
   int xyarr[4];
   char c;
   
   file[0]='C';
   file[1]='L';
   file[2]='I';
   file[3]='P';
   file[4]='.';
   file[5]='I';
   file[6]='M';
   file[7]='G';
   file[8]=0;
   
   

   
   w_in[0]=1;
   w_in[10]=2;
   v_opnwk(&w_in, &handle, &w_out);
   v_clrwk(handle);
   v_bit_image(handle, &file, 1, 0, 0, 0, 0, &xyarr);
   
   
   
      
   return 0;
}


however it won't work. Can someone help me please?

Yod801
Retro freak
Retro freak
Posts: 13
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Postby Yod801 » Thu Feb 15, 2018 1:29 pm

oh yeah I've got NVDI5 installed and CLIP.IMG in my project folder. Programming on Tos2.06

ThorstenOtto
Captain Atari
Captain Atari
Posts: 400
Joined: Sun Aug 03, 2014 5:54 pm

Re: v_bit_image

Postby ThorstenOtto » Thu Feb 15, 2018 3:28 pm

When drawing on screen, you must not use v_opnwk()/v_clswk(). Use v_opnvwk()/v_clsvwk instead, using the physical workstation of AES which is returned by graf_handle(). Also, i'm not sure wether v_bit_image() works at all for screen handles, i think its main purpose is when used by a GDOS printer device.

LuigiThirty
Atari maniac
Atari maniac
Posts: 75
Joined: Sat Sep 03, 2016 12:20 am

Re: v_bit_image

Postby LuigiThirty » Thu Feb 15, 2018 3:56 pm

You can also do char file[13] = "CLIP.IMG" ;)

Yod801
Retro freak
Retro freak
Posts: 13
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Postby Yod801 » Thu Feb 15, 2018 4:30 pm

@LuigiThirty, yeah, I'm aware of that. I'm just getting back to C.
@ThorstenOtto: How do I display an IMG file then?

ThorstenOtto
Captain Atari
Captain Atari
Posts: 400
Joined: Sun Aug 03, 2014 5:54 pm

Re: v_bit_image

Postby ThorstenOtto » Thu Feb 15, 2018 6:18 pm

Yod801 wrote:@ThorstenOtto: How do I display an IMG file then?


Load it into memory, decompress it, and display it using vrt_cpyfm() (assuming it is a monochrome image). For color images, that will be much more complicated because you then have to convert it into the internal format used by VDI (which can be almost anything, eg interleaved planes format as used in the original ST color modes, or 8-bit color indexed, or 16-bit hi-color, or 32-bit truecolor), then display it using vro_cpyfm(). Or install an accessory like ZView, and tell it to display the image by sending it a VA_START message ;)

Yod801
Retro freak
Retro freak
Posts: 13
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Postby Yod801 » Fri Feb 16, 2018 3:28 pm

OK, ta! That's still a lot to work out. Can someone point me to a proper Atari ST .IMG file documentation?

Yod801
Retro freak
Retro freak
Posts: 13
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Postby Yod801 » Mon Feb 19, 2018 3:31 pm

BTW: found a documentation and worked it out. Now it's time to actually program this. When I got it in black and and white, I''ll head to colour mode with the final goal of programming a shoot'em'up. First I need to repair my bike though

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1747
Joined: Sun Jul 31, 2011 1:11 pm

Re: v_bit_image

Postby Eero Tamminen » Mon Feb 19, 2018 7:09 pm

I have C-code for IMG image file reading/viewing here:
http://eerott.mbnet.fi/hatari/programs.shtml#ximg

I've ported the code to AHCC, so it should be pretty compatible with Pure-C too.

Yod801
Retro freak
Retro freak
Posts: 13
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Postby Yod801 » Tue Mar 13, 2018 3:25 pm

Thank you, Fero_Tamminem: After I found out that my own code was buggy, I used your depack_img() function and it all works now


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 4 guests