Welcome, Guest. Please login or register.

Author Topic: Pen Independent Images.  (Read 4614 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Pen Independent Images.
« on: August 06, 2007, 06:55:10 PM »
I posted this over on UtilityBase, but thought I'd post it here too to see if I can find the answer more quickly:

========================================
Alright, I'm goofing around again, messing around with ancient Amiga programs. I have an old program that displays images to a WB window. Naturally, it's limited to a very low color depth. The Workbench I'm running, however, is RTG (UAE) so colors are unlimited.

I've spent most of the evening searching aminet for any kind of example that would allow me to draw images that are not limited to a low color WB but with no success. It's now tired, and I'm getting late, so am appealing to UB for clues to the right direction.

So, what's the best approach to draw non-pen dependent images in a workbench window? Does any one know of any tutorials? Example programs? As always, any and all clues appreciated. :)

Thomas responded:
Quote
Use WritePixelArray


To which, I replied:

Thanks, Thomas, that helps but leaves me with more questions.

Looking at Olaf Barthel's ViewILBM (Aminet), I found an example of how to do that but it's so complex I'm having a tough time figuring out what to do.

WritePixelArray needs a BitPlaneData structure which ViewILBM initializes with an routine called OpenAsync that appears to be assembler and leaves me clueless.

What's the best (and easiest) way to populate this BitPlaneData structure?

Keep them clues coming...

Thanks,
Ed.
========================================

So, can anyone else offer me some clues here? All help appreciated. :)
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #1 on: August 06, 2007, 07:05:41 PM »
Thanks, Piru, I did look at the AutoDoc, but, unfortunately, I don't know how to read it (yet). At the moment, I'm looking for some advice, and/or simple examples of how to accomplish this. To me, that's by far more understandable than the AutoDoc. :-)

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #2 on: August 06, 2007, 07:29:24 PM »
All right, checking the examples on UtilityBase, I found this. It's not WritePixelArray, but it looks like it would accomplish my purposes: ex01_p96WriteTrueColorData.c.

If I use this, what are the compatibility issues with other Amigas? Just curious.

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #3 on: August 06, 2007, 07:37:39 PM »
Dude! Excellent. Simple and concise. I owe you one. :-) I'll give it a try later when I have a second.

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #4 on: August 06, 2007, 07:56:44 PM »
Turns out I didn't have to take off as quickly as I thought...

So, I tried the example Piru provided but it won't compile. The compiler complains "can't find '#include '  and '#include '."

I'm using NDK 3.9 and AmiDevCpp. Any clues what I'm might be doing wrong here?

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #5 on: August 06, 2007, 08:25:32 PM »
Downloaded a CG Library from this link: http://aweb.sunsite.dk/files/dev/cgfx-sdk.lha

The program compiles but does not link. I get this error: Unresolved error to _IntutionBase.

Bare with me. C is not my first (programming) language. ;)

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #6 on: August 07, 2007, 01:25:35 AM »
I got it to compile.  :banana:  

The problem wasn't with AmiDevCpp; my system needed a reboot, apparently.

Thanks for the help, Piru. May I upload your example to UtilityBase so that there actually is an example there? :-)

A couple quick questions before I move on. Do you know if there are there similar routines for BOBS and Sprites? What are they?

Now I need to figure out how to load a PNG or an IFF into the array you provided. I'll spend some time trying to figure that out, but if you want to clue me in on that one too, I won't complain to loudly. ;-)

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #7 on: August 07, 2007, 06:57:51 PM »
I'd like to learn datatypes but right now I'm trying to keep this simple.

I don't necessarily need to read png, I just want to load an image for now. I've learned that PPaint, for example, will save to C datatypes, but this is clearly not the format needed by your example. I found another tool that saves to "raw" which I'm not familiar with, but assume it is the RGB values used by your example. If I read a raw image straight into an array, should it work? Curious as always.

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #8 on: August 08, 2007, 05:35:21 AM »
@ Piru

There's a tool on Aminet (and included with Amikit) called GfxCon that converts between many different formats, including what it calls "RGB-Raw." I've no clue if this is ARGB or RGBA format, but I suspect I'll find out once I begin to experiment with it.

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #9 on: August 17, 2007, 07:16:20 AM »
All right, following up on this, I took Piru's example and changed the part where he populated the array variable with this bit of code:
Code: [Select]
     while(!done) {
          UBYTE a; if (!done) if (!(a = fgetc(test))) done = TRUE;
          UBYTE r; if (!done) if (!(r = fgetc(test))) done = TRUE;
          UBYTE g; if (!done) if (!(g = fgetc(test))) done = TRUE;
          UBYTE b; if (!done) if (!(b = fgetc(test))) done = TRUE;
          if (!done) array[y * WIDTH + x] = (r << 16) | (g << 8) | b;
      }


Unfortunately, and not unexpectedly, all I got was garbage. I even switched the "UBYTE a" variable from first to last to account for the differences between ARGB and RGBA. I may be approaching this completely wrong and may have made a number of bad assumptions. As always, if ya gots some clues, please enlighten me. :-)

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show all replies
    • http://www.EdwardGDanaII.info
Re: Pen Independent Images.
« Reply #10 on: August 17, 2007, 04:54:47 PM »
I figured it out... The raw format I was using has no alpha channel, so it was simple RGB, not RGBA or ARGB. Also, I needed to redefine char to UBYTE, like so:
Code: [Select]
         UBYTE r = (UBYTE)fgetc(test);
          UBYTE g = (UBYTE)fgetc(test);
          UBYTE b = (UBYTE)fgetc(test);


Ed.
Ed.