• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 21:49
CEST 03:49
KST 10:49
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO8 Preview0[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event11Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced9
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
GSL Code S Season 1 (2026) Sparkling Tuna Cup - Weekly Open Tournament RSL Revival: Season 5 - Qualifiers and Main Event StarCraft Evolution League (SC Evo Biweekly) 2026 GSL Season 2 Qualifiers
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ Do we have a pimpest plays list? AI Question ASL21 General Discussion
Tourneys
[ASL21] Ro8 Day 4 [Megathread] Daily Proleagues [ASL21] Ro8 Day 3 [ASL21] Ro8 Day 2
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV OutLive 25 (RTS Game) Daigo vs Menard Best of 10 Nintendo Switch Thread
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Formula 1 Discussion McBoner: A hockey love story
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Movie Stars In Video Games: …
TrAiDoS
ramps on octagon
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1458 users

The Big Programming Thread - Page 279

Forum Index > General Forum
Post a Reply
Prev 1 277 278 279 280 281 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
tec27
Profile Blog Joined June 2004
United States3702 Posts
March 30 2013 22:14 GMT
#5561
On March 29 2013 22:51 Nausea wrote:
Show nested quote +
On March 29 2013 21:17 ddengster wrote:
To answer your example, you can change the z-values to some unique value (something which you know you will probably never hit)when you 'drop' it. And you could loop over all the windows for the highest z values and assign the next highest z to the window you want. Or even define a 'highest' z value that the whole UI system follows.


Thank you. I got another answer on gamedev which I think I will try.

"Instead of storing the window pointers in a vector, store them in the list. Mouse testing is then done from top to bottom, and drawing is done from bottom to top. Moving a window to the top requires that the window be removed and added to the front of the list."

You can also just store your windows in a linked list, ordered by last focus. Draw from back to front, test for input from front to back. Whenever you focus a window, remove that window from the linked list and add it back at the head. Should be simpler and faster than checking a bunch of z-value numbers
Can you jam with the console cowboys in cyberspace?
necrosexy
Profile Joined March 2011
451 Posts
March 31 2013 03:08 GMT
#5562
JAVA

i'm trying to average a color from subimages of a bufferedimage.
i'm using the getRGB(int, int, int, int, int[], int, int) method that returns an integer array,
but the array is filled with large negative integers.
How do I use these to average the color?
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2013-03-31 03:35:42
March 31 2013 03:32 GMT
#5563
This may be of assistance:

http://docs.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html#getRGB(int, int, int, int, int[], int, int)
http://stackoverflow.com/questions/6001211/format-of-type-int-rgb-and-type-int-argb

Recall that an int in java is 32 bits. Look at this like 4 bytes:

10101010 | 10101010 | 10101010 | 10101010

With TYPE_INT_ARBG, you get 4 bytes, a (alpha), r (red), b (blue), g (green) in order. So you get 8 bits of each color, and 8 bits of alpha:

aaaaaaaa | rrrrrrrr | bbbbbbbb | gggggggg

I don't know how you're defining average color, but presumably you want to separate out the r, b, and g portions (dunno if you care about alpha).

You're going to have to learn how to do bit shifting 'n shit for that, unless BufferedImage has helper methods. See if you can dig up helper methods for dealing with TYPE_INT_ARBG. If not, have fun with the >> & bullshit


Also this may be one of those things that gets fucked up on big vs. little endian, but probably not if you're only using java. I think java may be stuck at big endian regardless of your comp's architecture. Perhaps.
Who after all is today speaking about the destruction of the Armenians?
necrosexy
Profile Joined March 2011
451 Posts
Last Edited: 2013-03-31 04:36:25
March 31 2013 04:31 GMT
#5564
On March 31 2013 12:32 phar wrote:
This may be of assistance:

http://docs.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html#getRGB(int, int, int, int, int[], int, int)
http://stackoverflow.com/questions/6001211/format-of-type-int-rgb-and-type-int-argb

Recall that an int in java is 32 bits. Look at this like 4 bytes:

10101010 | 10101010 | 10101010 | 10101010

With TYPE_INT_ARBG, you get 4 bytes, a (alpha), r (red), b (blue), g (green) in order. So you get 8 bits of each color, and 8 bits of alpha:

aaaaaaaa | rrrrrrrr | bbbbbbbb | gggggggg

I don't know how you're defining average color, but presumably you want to separate out the r, b, and g portions (dunno if you care about alpha).

You're going to have to learn how to do bit shifting 'n shit for that, unless BufferedImage has helper methods. See if you can dig up helper methods for dealing with TYPE_INT_ARBG. If not, have fun with the >> & bullshit


Also this may be one of those things that gets fucked up on big vs. little endian, but probably not if you're only using java. I think java may be stuck at big endian regardless of your comp's architecture. Perhaps.

i'm trying to pixelate an image. so i'm trying average the color of each subimage, acting as a huge pixel in the final image.

we haven't gone over bit shifting in class, so i think a solution shouldn't involve that :s

i separated the colors, but how i do converted them back into an rgbarray[] ? i'm using the corresponding setRGB(...) with 6 args

not generalized ...
for(int y = 0; y < height - 54; y += 53) {
for(int x = 0; x < width - 72; x += 71) {

img.getSubimage(x, y, 71, 53).getRGB(
0, 0, 71, 53, samples, 0, 71);

for(int i = 0; i < samples.length - 1; i++) {
colorSum += samples[i];
System.out.println(samples[i]);
}

for(int i = 0; i < samples.length - 1; i++)
Color c = new Color(samples[i]);
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
}
//calculate average of each color ...
pixelated.getSubimage(x, y, 70, 52).setRGB(0, 0,
70, 52, samples, 0, 70);
}
necrosexy
Profile Joined March 2011
451 Posts
Last Edited: 2013-03-31 04:37:42
March 31 2013 04:37 GMT
#5565
dp .
Try
Profile Blog Joined August 2007
United States1293 Posts
March 31 2013 04:44 GMT
#5566
Bit of a stretch to post it here, but anyone on TL at the Chicago Invitational ICPC Programming Contest this Weekend?
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-03-31 18:42:18
March 31 2013 18:39 GMT
#5567
Java

When I use socket.getInetAddress(), I usually get this format: /IP
I'd like to change it to only "IP" without the forward slash. Any ideas? I'm currently thinking of override, but how do I know what variable should I use?

E.g.


@override
public String toString() {
return inetAddress;
}


Or do I have to use some kind of string manipulation to get only the IP out of this method getInetAddress()?
JeanLuc
Profile Joined September 2010
Canada377 Posts
Last Edited: 2013-03-31 18:59:40
March 31 2013 18:52 GMT
#5568
On March 31 2013 12:08 necrosexy wrote:
JAVA

i'm trying to average a color from subimages of a bufferedimage.
i'm using the getRGB(int, int, int, int, int[], int, int) method that returns an integer array,
but the array is filled with large negative integers.
How do I use these to average the color?


This isn't java, but it may be of use to you. Basically you can pixelate images on an html5 canvas, or otherwise manipulate the colour values of each pixel. I've seen a bunch of tutorials on this, this is what I found from a google search right now

http://www.html5canvastutorials.com/labs/html5-canvas-pixelated-image-focus/

Hope this helps

Edit: http://html5doctor.com/video-canvas-magic/
If you can't find it within yourself to stand up and tell the truth-- you don't deserve to wear that uniform
necrosexy
Profile Joined March 2011
451 Posts
April 01 2013 00:02 GMT
#5569
On April 01 2013 03:52 JeanLuc wrote:
Show nested quote +
On March 31 2013 12:08 necrosexy wrote:
JAVA

i'm trying to average a color from subimages of a bufferedimage.
i'm using the getRGB(int, int, int, int, int[], int, int) method that returns an integer array,
but the array is filled with large negative integers.
How do I use these to average the color?


This isn't java, but it may be of use to you. Basically you can pixelate images on an html5 canvas, or otherwise manipulate the colour values of each pixel. I've seen a bunch of tutorials on this, this is what I found from a google search right now

http://www.html5canvastutorials.com/labs/html5-canvas-pixelated-image-focus/

Hope this helps

Edit: http://html5doctor.com/video-canvas-magic/

i figured it out. i was on the right track.

[...]
avgR = r / samples.length;
avgG = g / samples.length;
avgB = b / samples.length;

//assign average to samples[]
for(int i = 0; i < samples.length - 1; i++) {
Color c = new Color(avgR, avgG, avgB);
samples[i] = c.getRGB();
}

//set pixels of the average colors from samples[]
//to the blank BufferedImage 'pixelated'
pixelated.getSubimage(x, y, xOffset, yOffset).setRGB(0, 0,
xOffset, yOffset, samples, 0, xOffset);

int r = 0; int g = 0; int b = 0;
}

n0ise
Profile Joined April 2010
3452 Posts
April 01 2013 17:16 GMT
#5570
Anyone here familiar with Eclipse RCP?

Could use a bit of help
Isualin
Profile Joined March 2011
Germany1903 Posts
Last Edited: 2013-04-01 19:36:43
April 01 2013 19:36 GMT
#5571
Anyone tried pythonchallenge? I am at question #5 now and its been fun so far
| INnoVation | The literal god TY | ByuNjwa | LRSL when? |
lannisport
Profile Joined February 2012
878 Posts
April 01 2013 20:56 GMT
#5572
Can anyone recommend any WAMP tutorials or paid classes? I started developing my website locally but couldn't get it to communicate with the Amazon API so I did a nono and just edited my live site. But I landed a project and I want to do it properly so I'm starting with bootstrap (also downloaded sublime text which is awesome).

Also with this site it's not that big so after I develop it on WAMP it'll probably be easy to just ftp the site when it's finished. But in general how do you deploy a larger website or web app? Or what if you need to make adjustments? Do you make every adjustment locally first then upload? Is there some sort of web development framework I can follow?
tofucake
Profile Blog Joined October 2009
Hyrule19210 Posts
April 01 2013 23:01 GMT
#5573
Generally it's something like

Production, Development, Sandbox

And most ISPs block home servers. You're best off renting a server from an actual server company and using your home WAMP setup as your sandbox/development server.
Liquipediaasante sana squash banana
lannisport
Profile Joined February 2012
878 Posts
Last Edited: 2013-04-02 01:08:31
April 02 2013 01:07 GMT
#5574
On April 02 2013 08:01 tofucake wrote:
Generally it's something like

Production, Development, Sandbox

And most ISPs block home servers. You're best off renting a server from an actual server company and using your home WAMP setup as your sandbox/development server.


Thanks for the info. I think I can just make a subdomain on my webhost and just dump the database and all the files onto it. I was looking at Git but it seems pretty complicated (I'm not even good with basic command line) and more powerful than what I really need. But it has just the features I'm looking for. Version control would be nice, speedy cloning would be desirable for quick "pulls and pushes". Having the ability to just download the site off a central server work on it locally and upload it after modifications in a quick and easy manner would be great because I usually have other programmers to do the actual development of parts of the site. Can you recommend an easy one with a GUI (and even a development server/environment)?
AmericanUmlaut
Profile Blog Joined November 2010
Germany2594 Posts
April 02 2013 08:40 GMT
#5575
On April 02 2013 10:07 lannisport wrote:
Show nested quote +
On April 02 2013 08:01 tofucake wrote:
Generally it's something like

Production, Development, Sandbox

And most ISPs block home servers. You're best off renting a server from an actual server company and using your home WAMP setup as your sandbox/development server.


Thanks for the info. I think I can just make a subdomain on my webhost and just dump the database and all the files onto it. I was looking at Git but it seems pretty complicated (I'm not even good with basic command line) and more powerful than what I really need. But it has just the features I'm looking for. Version control would be nice, speedy cloning would be desirable for quick "pulls and pushes". Having the ability to just download the site off a central server work on it locally and upload it after modifications in a quick and easy manner would be great because I usually have other programmers to do the actual development of parts of the site. Can you recommend an easy one with a GUI (and even a development server/environment)?

Git has many GUIs (http://git-scm.com/downloads/guis), and is very easy to use for basic version control. SVN is also good, but not really any easier to use.
The frumious Bandersnatch
althaz
Profile Joined May 2010
Australia1001 Posts
Last Edited: 2013-04-02 10:25:14
April 02 2013 10:24 GMT
#5576
On March 29 2013 03:18 ZenithM wrote:
Show nested quote +
On March 29 2013 03:10 POiNTx wrote:

try
{
statements;
}
catch (ExceptionClass e)
{
statements
}


I think that is even more readable.

This is another well-established coding convention, and what is standard in C# (see Microsoft's guidelines here: http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx). But what darkness proposed was a really weird and ugly hybrid form of the Java standard and the C# one :D
As someone said, as long as everybody who works on the same code uses the same conventions that's fine, but it's better to pick up established conventions as your own to begin with.

I personally follow the Oracle Java Code conventions to code in Java and the Microsoft guidelines to code in C#. I believe it's good to be able to follow flexibly whatever convention you have to use in a given situation.

Edit: Damn and it's been such a long time since I've written some C#. I need me some C#
It's so much more cool, fun and powerful than Java... :'(

C# is my language of choice so I also use this format. It's by far (IMO) the most readable. But of course when I am asked (usually this involves force) to use other languages, I use their conventions if I am aware of them.
The first rule we don't talk about race conditions. of race conditions is
lannisport
Profile Joined February 2012
878 Posts
April 02 2013 15:54 GMT
#5577
On April 02 2013 17:40 AmericanUmlaut wrote:
Show nested quote +
On April 02 2013 10:07 lannisport wrote:
On April 02 2013 08:01 tofucake wrote:
Generally it's something like

Production, Development, Sandbox

And most ISPs block home servers. You're best off renting a server from an actual server company and using your home WAMP setup as your sandbox/development server.


Thanks for the info. I think I can just make a subdomain on my webhost and just dump the database and all the files onto it. I was looking at Git but it seems pretty complicated (I'm not even good with basic command line) and more powerful than what I really need. But it has just the features I'm looking for. Version control would be nice, speedy cloning would be desirable for quick "pulls and pushes". Having the ability to just download the site off a central server work on it locally and upload it after modifications in a quick and easy manner would be great because I usually have other programmers to do the actual development of parts of the site. Can you recommend an easy one with a GUI (and even a development server/environment)?

Git has many GUIs (http://git-scm.com/downloads/guis), and is very easy to use for basic version control. SVN is also good, but not really any easier to use.


Thanks for this sir. Sublime text is awesome btw! It's gonna make learning python a whole lot funner.
DMII
Profile Joined September 2011
Germany92 Posts
April 02 2013 18:20 GMT
#5578
I am currently trying to get into the habit of working on something every day, because I think I am a way too lazy person.
The problem with this is, that I want to start small but only get ideas which are a little too big for my taste. However, it also lead to a question, which is less linked to my own problems, but interesting in general. At least for people interested in programming.

What programs should every programmer write at least once in his life?
What kind of functionality should every programmer implement at least once in his life? (Better version I found while writing this post. )

It's kind of like the question about which programming languages every programmer should know, just a little different since it isn't as much about the tools but about their application.
All is fair in love and war. Starcraft is both.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
April 02 2013 18:47 GMT
#5579
On April 03 2013 03:20 DMII wrote:
I am currently trying to get into the habit of working on something every day, because I think I am a way too lazy person.
The problem with this is, that I want to start small but only get ideas which are a little too big for my taste. However, it also lead to a question, which is less linked to my own problems, but interesting in general. At least for people interested in programming.

What programs should every programmer write at least once in his life?
What kind of functionality should every programmer implement at least once in his life? (Better version I found while writing this post. )

It's kind of like the question about which programming languages every programmer should know, just a little different since it isn't as much about the tools but about their application.


I like that attitude

Building something new every day is very difficult. I vaguely remember in the haze of my youth I went through a period where I programmed something new every day. I remember using programming competition problems as fodder, going through them by the pile until I got bored of algorithms.

From there I moved onto bigger projects, thinking of how to create programs which are based on features generated from the algorithms.

Then I went to college, gave up on CS and 'traditional programming', then learned more functional and math scripting as my needs required.

Finally, I'm back at programming, but more on the maintenance side.

Anywho, I got distracted.... If you're still looking into algorithms and implementation details, then find a good programming challenge website (there are dozens for each language). If you are trying to make the jump to features within a larger program, then try to write something like Conway's Game of Life. If you think you're up for the challenge, try to design projects based on your own need, then implement them and deploy them. You win if you can make 1$ from it.


Any sufficiently advanced technology is indistinguishable from magic
CorsairHero
Profile Joined December 2008
Canada9491 Posts
April 03 2013 00:15 GMT
#5580
man...double pointers Anyone going for a C programming job should look them up.
© Current year.
Prev 1 277 278 279 280 281 1032 Next
Please log in or register to reply.
Live Events Refresh
PiGosaur Cup
00:00
#80 (TLMC 22 Edition)
PiGStarcraft548
CranKy Ducklings64
EnkiAlexander 39
davetesta27
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft540
RuFF_SC2 142
CosmosSc2 32
StarCraft: Brood War
GuemChi 6241
Artosis 641
910 47
NaDa 24
Moletrap 11
Dota 2
monkeys_forever639
League of Legends
Doublelift4799
JimRising 696
Super Smash Bros
Mew2King71
Other Games
summit1g7333
tarik_tv6126
C9.Mang0552
ViBE30
Organizations
Other Games
gamesdonequick1080
BasetradeTV464
Dota 2
PGL Dota 2 - Main Stream37
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• Hupsaiya 74
• CranKy Ducklings SOOP7
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 29
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• Scarra1098
Upcoming Events
GSL
7h 41m
Classic vs Cure
Maru vs Rogue
GSL
1d 7h
SHIN vs Zoun
ByuN vs herO
OSC
1d 9h
OSC
1d 11h
Replay Cast
1d 22h
Escore
2 days
The PondCast
2 days
WardiTV Invitational
2 days
Zoun vs Ryung
Lambo vs ShoWTimE
OSC
2 days
Replay Cast
2 days
[ Show More ]
CranKy Ducklings
3 days
RSL Revival
3 days
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
3 days
Krystianer vs TriGGeR
Cure vs Rogue
uThermal 2v2 Circuit
3 days
BSL
3 days
Replay Cast
3 days
Sparkling Tuna Cup
4 days
RSL Revival
4 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
4 days
BSL
4 days
GSL
5 days
Afreeca Starleague
5 days
Monday Night Weeklies
5 days
Afreeca Starleague
6 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Proleague 2026-05-05
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
YSL S3
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W6
KK 2v2 League Season 1
BSL 22 Non-Korean Championship
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.