Plotting problem;

Hi;

I don't think this is possible but I hope I'm wrong.

I have a large bitmap image and I want to add some dots of different colors to it.

I can read the file, save it as a box string and box show the result but all I get is the lower left corner.

I need to scroll the image in both directions, overlay a movable ruler and plot filled circles.

Is it possible?

Roger

Comments

Displaying large images

It certainly is possible.
Find out how big the image is in pixels.
Find out how big your window is in pixels e.g.
ASK PIXELS xpix,ypix
SET WINDOW 0,xpix-1,ypix-1,0
Now when you show your image you must BOX SHOW image$ AT left,bottom
where left,bottom are offset, for example, suppose your window is 600x400 and your image size is 1200x800 then if you wish to show the top right portion of your image then left offset=-600 and the bottom offset=800

Regards
Big John

Big John; The problem is

Big John;

The problem is that TB can only work on what's on the screen.

This image is 1000x2075 pixels while my screen is 944x667 pixels and I need to make changes in the whole image.

I don't need to see it; I just need to change and save it.

Roger

Ok, now I can scroll the

Ok, now I can scroll the image and add the dots to the whole image.

But I can only save what's on the screen which is about 1/3 of the image.

This means I can't print the final result in one page. I have to print it in sections and paste them together.

Roger

Large images

Hi Roger,

If you know the co-ordinates of the pixel you wish to change, i.e. the co-ordinates relative to the top left corner of the image - not the screen or the window, then I have a library module called BOXSTRINGS that allows you to change any pixel in an image without even displaying the image - and it is quick.

For more info see my website at:
www.bigjohnarscott.com

You can still use your existing display to show the image and the dots that you add. As you add each dot you call also "update" the boxstring (with the library above). Finally, when you are done, you just save the boxstring rather than save the image.

Regards
Big John

Big John; Excellent! I

Big John;

Excellent!

I suspected it was possible but the box string format is a bit beyond my ability.

Please, may I have that library?

Roger

Big John; Never mind; I have

Big John;

Never mind; I have it now and it's FAST!

But the enlarge part of the demo distorted the image.

Roger

BOXSTRINGS

Hi Roger,

I did mention in the documentation that enlarging or reducing the image tends to distort the image, particularly with magnifications approaching or exceeding times 2.

Regards
Big John

Big John; Yes, you did

Big John;

Yes, you did mention that and it isn't important to my task anyway.

But the one thing I do need is a way to write the image to a bitmap file. Read_image does bitmap to box conversion of the whole image but Write_image does only the screen.

I can't just write a box format because others who want to see it probably won't have TB.

Roger

WRITE_IMAGE

Hi Roger,

The built-in TB sub-routine Write_Image(type$,image$,filename$) is the one that lets you convert your boxstring (image$) into another format (MS BMP). Once you have it in MS BMP format you can convert it to JPG or anything else.

Regards
Big John
Big John

Big John; Yes but only

Big John;

Yes but only what's on the screen. My image is much larger than the screen.

Roger

boxstrings

Hi Roger,

Do you not have the whole image as a box string?
Have you been using the whole image string with the BOXSTRING library? If so then you can use Write_Image with the whole box string and write it to a bmp file regardless of what is on the screen. Or am I missing something?

Regards
Big John

Big John; I think I've been

Big John;

I think I've been doing it wrong. I was displaying the section that the screen will hold, box showing the dots and scrolling up/down as desired. When I did a write_image it was only for the screen contents because the dots were only there.

Now that I have your library I can put the dots on the image and save the whole image as desired.

The only problem now is figuring out about 500 pixel locations and making them look like a dot.

Roger

Big John; Here's a sample of

Big John;

Here's a sample of what I'm doing.


program bdots

LIBRARY "e:\TB Silver\tblibs\boxstrings.trc"
LIBRARY "e:\TB Silver\tblibs\TrueCtrl.trc"

CALL TC_init
CALL TC_setunitstopixels

open #3: screen 0,1,0,1
window #3

call read_image ("MS BMP",bks$,"e:\true\year charts\2009.bmp")
call boxstring_size(bks$,xpic,ypic)
set window 0,xpic,0,ypic

for x = 0 to xpic
call writeBOXpixel(bks$,x,100,255,128,0)
call writeBOXpixel(bks$,x,200,255, 0,0)
call writeBOXpixel(bks$,x,300,255,128,0)
call writeBOXpixel(bks$,x,400,255, 0,0)
call writeBOXpixel(bks$,x,500,255,128,0)
call writeBOXpixel(bks$,x,600,255, 0,0)
call writeBOXpixel(bks$,x,700,255,128,0)
next x
call write_image("MS BMP",bks$,"newplot.bmp")
stop

It should put a series of horizontal lines across the screen, alternately red and magenta but in fact nothing happens to the image.

Perhaps we should go to email?

rogerh@lpbroadband.net

Roger

Big John; Never mind, I

Big John;

Never mind, I found the problem.

It's an 8 bit image.

Do you have a library for that? Or a way to convert to 24 bit.

Roger

24 bit images

Hi Roger,

Try using MS Paint. Import the original image as 8 bit then save it as 24 bit.

Bu the way in your program fragment you define the window as
set window 0,xpic,0,ypic
I think you may have trouble later because I believe the BOXSTRING library depends on the y-axis getting larger down the page, i.e. the origin is top-left not bottom-left.

set window 0,xpic,ypic,0 ! should do the trick

Regards
Big John

Big John; MS Paint doesn't

Big John;

MS Paint doesn't give you a choice as far as I can tell.

But Gimp does and it's free.

Box string goes bottom to top because my first program was working that way.

Your library goes top to bottom so I had to reverse the y values. Also, drawing a pixel at a time is slow compared to a box show of the whole dot.

But it works and that's what counts.

Roger