v_bit_image

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

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

Post Reply
Yod801
Atariator
Atariator
Posts: 17
Joined: Mon May 15, 2017 5:50 pm

v_bit_image

Post by Yod801 »

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
Atariator
Atariator
Posts: 17
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Post by Yod801 »

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

ThorstenOtto
Atari God
Atari God
Posts: 1083
Joined: Sun Aug 03, 2014 5:54 pm

Re: v_bit_image

Post by ThorstenOtto »

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: 97
Joined: Sat Sep 03, 2016 12:20 am

Re: v_bit_image

Post by LuigiThirty »

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

Yod801
Atariator
Atariator
Posts: 17
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Post by Yod801 »

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

ThorstenOtto
Atari God
Atari God
Posts: 1083
Joined: Sun Aug 03, 2014 5:54 pm

Re: v_bit_image

Post by ThorstenOtto »

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
Atariator
Atariator
Posts: 17
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Post by Yod801 »

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

Yod801
Atariator
Atariator
Posts: 17
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Post by Yod801 »

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
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2108
Joined: Sun Jul 31, 2011 1:11 pm

Re: v_bit_image

Post by Eero Tamminen »

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
Atariator
Atariator
Posts: 17
Joined: Mon May 15, 2017 5:50 pm

Re: v_bit_image

Post by Yod801 »

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

Post Reply

Return to “C / PASCAL etc.”