I'm writing a program to manipulate jpg images, but have got stuck at an early proof of concept stage. I read all the RGB values of the 399 x 600 jpg into a 3-dimensional array (400,601,3), clear the screen then draw each pixel back from the array. But I only get one quarter of the image. Here's the essence of the code:
GRAPHICS
GRAPHICS CLEAR 1,1,1
OPTION BASE 0
DIM ORIG(400,601,3)
DRAW IMAGE "face10.jpg" AT 0,0 SCALE 1
FOR W = 0 TO 600
FOR V = 0 TO 399
GET PIXEL V,W COLOR R,G,B
ORIG(V,W,0) = R
ORIG (V,W,1) = G
ORIG (V,W,2) = B
NEXT V
NEXT W
GRAPHICS CLEAR 1,1,1
FOR W = 0 TO 600
FOR V = 0 TO 399
R = ORIG (V,W,0)
G = ORIG (V,W,1)
B = ORIG (V,W,2)
DRAW PIXEL V,W COLOR R,G,B,1
NEXT V
NEXT W
This redraws only the top left quarter of the original image. Interestingly, if I set the scale to 0.5 when drawing the original image, the whole image gets redrawn. Is there something obvious I'm missing? I'd be grateful for any insights. Further possibly relevant information is: screen size 1024 x 724; SCREEN_SCALE() = 2 (is this the key, and if so, how would I work with this?)
Partial Image conundrum
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Partial Image conundrum
Please do not post your topics into the "BASIC programs" section - that section is for finished programs only.
Regarding your question.
GET PIXEL command is screen-scale dependent. This may be the cause.
Screen scale means how many pixels are there in one point (in each direction). If screen scale is 2 then a point is 2x2 pixels size.
Regarding your question.
GET PIXEL command is screen-scale dependent. This may be the cause.
Screen scale means how many pixels are there in one point (in each direction). If screen scale is 2 then a point is 2x2 pixels size.