Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Community > MacNN Lounge > Quick! Help me with an algorithm

Quick! Help me with an algorithm
Thread Tools
tintub
Mac Elite
Join Date: Jan 2003
Location: Melbourne, AU (from Bristol UK)
Status: Offline
Reply With Quote
Sep 5, 2003, 07:56 AM
 
I have an image stored in an array as pixels, e.g.

[1,2,3,4] would correspond to pixel values of

1 2
3 4

in my image. I need to blow this image up, which means creating an array like this:

[1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4]

to make an image like this

1 1 1 2 2 2
1 1 1 2 2 2
1 1 1 2 2 2
3 3 3 4 4 4
3 3 3 4 4 4
3 3 3 4 4 4

I can make the arrays 2 dimensional if it makes things easier. FWIW, I'm using Java.

I am sure there is a simple solution, but I can't wrap my head around it at the moment. Usually the best thing to do is walk away for a bit and come back and it will seem obvious, but I want to get it done ASAP

[edit: N.B. The image is square. It's actually 11x11 pixels and I am blowing it up to 220x220 pixels. In fact I wonder if there is a built in method for blowing up images...]

[edit 2: there is (Image.getScaledInstance())]
( Last edited by tintub; Sep 5, 2003 at 08:32 AM. )
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:22 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,