Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Journal] Untitled Thought in Progress  (Read 2130 times)
0 Members and 1 Guest are viewing this topic.
Offline Roquen
« Posted 2010-04-22 16:25:35 »

Stub
Offline Roquen
« Reply #1 - Posted 2010-04-22 16:26:29 »


I'm working on a concept, that I'll hopefully have time to complete.  But for today I'd like to throw out the idea of allowing Pixel scaling methods.

My thought is that these are in the spirit of the contest and would make playing the entries more fun.  But if allowed would need to follow the rule:

The scaling method must be under end user control and should default to point sampling.  Also, to be fair to everyone, the method source should be made available.

Below I have my implementations of Scale2X & Scale3X.  These can be chained to create 4x & 6x.  I also have Hq{2,3,4}x, but are not really ready for realtime usage.  If TPTB decided that these methods are OK for usage, I'll try to complete them along with an 2xSai version.

Scale2X:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
public static final void convert(int[] dst, int[] src, int sw, int sh)
{
  int dw = sw+sw;
  int r0 = 0;
  int r1 = dw;

  int x, y;
  int pr = 0;
  int nr;
  int i = 0;
 
  // Input Sample Matrix
 //      c01    
 //  c10 c11 c12 ->
 //      c21    
 int     c01;
  int c10,c11,c12;
  int     c21;

  for (y=0; y<sh; y++) {
    if (y < sh-1) nr = sw; else nr = 0;
   
    c11 = src[i];
    c12 = src[i+1];

    for (x=0; x<sw; x++) {
      c10 = c11;
      c11 = c12;
      c01 = src[i + pr];
      c21 = src[i + nr];

      if (x < sw-1) c12 = src[i+1];

      if (c01 != c21 && c10 != c12) {
        dst[r0  ] = c10 == c01 ? c10 : c11;
        dst[r0+1] = c01 == c12 ? c12 : c11;
        dst[r1  ] = c10 == c21 ? c10 : c11;
        dst[r1+1] = c21 == c12 ? c12 : c11;
      }
      else
        dst[r0] = dst[r0+1] = dst[r1] = dst[r1+1] = c11;

      r0 += 2;
      r1 += 2;
      i++;
    }
   
    pr  = -sw;
    r0  = r1;
    r1 += dw;
  }
}


Scale3X:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
public static final void convert(int[] dst, int[] src, int sw, int sh)
{
  int i = 0;
  int x, y;
  int pr = 0;
  int nr;
  int dx = sw * 3;
  int r0 = 0;
  int r1 = dx;
  int r2 = r1 + dx;

  // Input Sample Matrix
 //   c00 c01 c02
 //   c10 c11 c12 ->
 //   c20 c21 c22

  int c00,c01,c02;
  int c10,c11,c12;
  int c20,c21,c22;

  for (y = 0; y < sh; y++) {
    if (y < sh - 1)
      nr = sw;
    else
      nr = 0;

    for (x = 0; x < sw; x++) {
      c01 = src[i + pr];
      c11 = src[i];
      c21 = src[i + nr];

      if (x > 0) {
        c00 = src[i + pr - 1];
        c10 = src[i - 1];
        c20 = src[i + nr - 1];
      }
      else {
        c00 = c01;
        c10 = c11;
        c20 = c21;
      }

      if (x < sw - 1) {
        c02 = src[i + pr + 1];
        c12 = src[i + 1];
        c22 = src[i + nr + 1];
      }
      else {
        c02 = c01;
        c12 = c11;
        c22 = c21;
      }

      i++;
     
      if ((c01 != c21) && (c10 != c12)) {
        boolean t0 = c01 == c12;
        boolean t1 = c10 == c21;
        boolean t2 = c11 != c02;
        boolean t3 = c11 != c20;
       
        if (c11 != c00) {
          if (c10 == c01) {
            dst[r0  ] = c10;                
            dst[r0+1] = t0 || t2 ? c01 : c11;
            dst[r1  ] = t1 || t3 ? c10 : c11;
          }
          else {
            dst[r0  ] = c11;          
            dst[r0+1] = t0 ? c01 : c11;
            dst[r1  ] = t1 ? c10 : c11;
          }
        }
        else {
          if (c10 == c01) {
            dst[r0  ] = c10;          
            dst[r0+1] = t2 ? c01 : c11;
            dst[r1  ] = t3 ? c10 : c11;
          }
          else {
            dst[r0  ] = c11;
            dst[r0+1] = c11;
            dst[r1  ] = c11;
          }
        }

        if (c11 != c22) {
          if (c21 == c12) {
            dst[r2+2] = c12;
            dst[r1+2] = t0 || t2 ? c12 : c11;
            dst[r2+1] = t1 || t3 ? c21 : c11;
          }
          else {
            dst[r2+2] = c11;          
            dst[r1+2] = t0 ? c12 : c11;
            dst[r2+1] = t1 ? c21 : c11;
          }
        }
        else {
          if (c21 == c12) {
            dst[r2+2] = c12;          
            dst[r1+2] = t2 ? c12 : c11;
            dst[r2+1] = t3 ? c21 : c11;
          }
          else {
            dst[r2+2] = c11;
            dst[r1+2] = c11;
            dst[r2+1] = c11;
          }
        }

        dst[r0+2] = t0 ? c12 : c11;
        dst[r2  ] = t1 ? c10 : c11;
      }
      else {
        dst[r0  ] =
        dst[r0+1] =
        dst[r0+2] =
        dst[r1  ] =
        dst[r1+2] =
        dst[r2  ] =
        dst[r2+1] =
        dst[r2+2] = c11;
      }

      dst[r1+1] = c11;

      r0 += 3;
      r1 += 3;
      r2 += 3;
    }
   
    pr = -sw;
    r0 = r2;
    r1 = r0+dx;
    r2 = r1+dx;
  }
}

Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #2 - Posted 2010-04-22 21:43:45 »

I think someone already unsuccessfully asked about upscaling.  It makes things look nicer at x2 or x4, but at higher levels of magnification the benefit seemed questionable.  Anyway it was ruled out (I think)

Incidentally, you can set rendering hints to get a choice of three upscaling algorithms in Java2D. E.g.

1  
2  
3  
4  
5  
6  
    public void paint1(Graphics g, int x, int y, int magnify) {
        consolidate();
        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.drawImage(this, x, y, magnify*getWidth(), magnify*getHeight(), null);
    }

Time flies like a bird. Fruit flies like a banana.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ShannonSmith
« Reply #3 - Posted 2010-04-22 23:00:16 »

I think if we allow methods of up-scaling other than nearest neighbour it will detract from the theme as it will no longer be clear that the game was generated at such a low resolution. Nearest neighbour up-scaling helps to emphasize the theme of the competition by exaggerating the pixelization. If enough participants disagree I'll run a poll and we can vote but otherwise we'll stick with nearest neighbour as the only allowed up-scaling method.
Offline Galaxy613

Senior Newbie





« Reply #4 - Posted 2010-04-22 23:48:14 »

I personally don't have a problem with smooth scaling, as long as it's JUST smooth scaling and isn't hiding a larger resolution. Not sure how we'll verify that other than forcing people to show their rendering code or counting width and height of the pixels shown throughout play. So I understand you wanted to avoid this Shannon.

If a poll was setup I'll vote for possible up-scaling, but I don't really care either way.

Programming since 2001 (Technically Tongue )
Uses: BlitzMax, Java, C++
Computers: W7 Desktop and a Triple Booting Netbook.
Offline Markus_Persson

JGO Wizard


Medals: 15
Projects: 19


Mojang Specifications


« Reply #5 - Posted 2010-04-23 07:58:58 »

I think if we allow methods of up-scaling other than nearest neighbour it will detract from the theme as it will no longer be clear that the game was generated at such a low resolution. Nearest neighbour up-scaling helps to emphasize the theme of the competition by exaggerating the pixelization. If enough participants disagree I'll run a poll and we can vote but otherwise we'll stick with nearest neighbour as the only allowed up-scaling method.

Anything but nearest neighbor totally destroys the point of the compo..

Play Minecraft!
Offline Roquen
« Reply #6 - Posted 2010-04-25 09:41:33 »

@Alan_W: Traditional filter don't work well.  The source image from signal processing standpoint doesn't match.  Bi-linear, cubic, etc are fine for Gaussian images, but simply create a mess for pixel art which are a unnatural mix of very high and very low frequencies (text and raster images of vector art fall in the same category).  Methods which do work well are based on either pattern matching or mathematical morphology.

@ShannonSmith & Markus_Persson: OK. I wanted to toss out the idea.  Again, this thought was more for the fun-factor than anything else.  (Thinking: fake retro game.  Where it a real retro game, it would probably be run in an emulator, which generally support these kinds of techniques).  Since obviously not everyone "jazzed" about the idea, I'll drop it.

FYI.  From tests against mock-up images, the output looks like a really cheesy flash game (given the limited resolution & colors)
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (11 views)
2014-09-21 23:33:17

BurntPizza (28 views)
2014-09-21 02:42:18

BurntPizza (19 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (47 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!