Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
When I run this, I get a minimap but it's a weird color for some of the blocks and some of the blocks are faded. It's extremely inefficient right now, so any optimization tips would be cool too.
This is based off of Capasha's minimap generator, except I just extracted the minimap part.
using System;
using System.Collections.Generic;
using PlayerIOClient;
using System.Threading;
using System.Drawing;
using System.Drawing.Imaging;
namespace MinimapGenerator
{
class Program
{
private bool readBlocks;
public static string blocks = BlockData.theblocks;
static private Color UIntToColor(uint color)
{
byte a = (byte)(color >> 24);
byte r = (byte)(color >> 16);
byte g = (byte)(color >> 8);
byte b = (byte)(color >> 0);
return Color.FromArgb(a, r, g, b);
}
private static void readWorld(string id)
{
//Trying to login..
PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", "guest", "guest", null,
delegate (Client c)
{
//Logged in.
c.BigDB.Load("Worlds", id, delegate (DatabaseObject worlds)
{
processWorlds(worlds);
});
});
}
private static void processWorlds(DatabaseObject worlds)
{
string fileName = "image.png";
string[] lines = blocks.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
var blockDict = new Dictionary<string, string>();
foreach (var line in lines)
{
string[] tmp = line.Split(new string[] { " " },StringSplitOptions.None);
blockDict.Add(tmp[0], tmp[1]);
}
if (worlds != null && worlds.Contains("worlddata"))
{
Bitmap bmp;
//Reading and saving WorldData.
string worldName = worlds.Contains("name") ? worlds.GetString("name") : "Untitled World";
int width = worlds.Contains("width") ? worlds.GetInt("width") : 0;
int height = worlds.Contains("height") ? worlds.GetInt("height") : 0;
DatabaseArray worlddata = worlds.GetArray("worlddata");
// Bitmap object
bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppRgb); // This is just a black rectangle
for (int i = 0; i < worlddata.Count; i++)
{
if (worlddata[i] == null) continue;
DatabaseObject worldinfo = worlddata.GetObject(i);
byte[] x = worldinfo.GetBytes("x");
byte[] y = worldinfo.GetBytes("y");
uint bid = worldinfo.GetUInt("type");
for (int p = 0; p < x.Length; p += 2)
{
int xx = x[p] << 8 | x[p + 1];
int yy = y[p] << 8 | y[p + 1];
var bid_ = Convert.ToInt32(bid);
try
{
bmp.SetPixel(xx, yy, UIntToColor(
Convert.ToUInt32(blockDict[bid_.ToString()])
));
} catch (Exception e)
{
bmp.SetPixel(xx, yy, UIntToColor(Convert.ToUInt32(16777216))); // black pixel
}
try {
Console.WriteLine(p / (float)x.Length * ((float)i / worlddata.Count));
} catch (Exception e)
{
}
}
}
bmp.Save(fileName, ImageFormat.Png);
bmp.Dispose();
}
}
static void Main(string[] args)
{
readWorld("PWc9u3pmFxa0I");
Thread.Sleep(Timeout.Infinite);
}
}
}
BlockData.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MinimapGenerator
{
static class BlockData
{
static public string theblocks = "9 4285427310\n10 4281684648\n11 4288099751\n12 4289213780\n1018 4289873185\n13 4287866933\n14 4282558518\n15 4281704102\n182 4279834905\n37 4291715791\n38 4283091074\n1019 4280918697\n39 4283270342\n40 4291782224\n1020 4289354281\n41 4291995973\n42 4288321167\n1021 4281019179\n1022 4284637794\n16 4287315465\n1023 4278788452\n17 4280577869\n18 4283311215\n19 4282614544\n20 4285473833\n21 4285488420\n1024 4279769112\n29 4288783269\n30 4292835905\n31 4293962023\n34 4282737427\n35 4282737427\n36 4282737427\n22 4287191826\n32 4291792930\n33 4278190080\n44 16777216\n45 4285686091\n46 4285426528\n47 4287525711\n48 4286533419\n49 4285887861\n243 16777216\n51 4294480537\n52 4293495798\n53 4289169910\n54 4286487030\n55 4288011510\n56 4287822762\n57 4294498956\n58 4294359700\n70 4293787648\n71 4293787886\n72 4278190318\n73 4278251246\n74 4278251008\n75 4293848576\n76 4293818112\n78 4286496276\n79 4291004548\n80 4288234511\n81 4283832702\n82 4283860245\n6 4281080346\n7 4279905306\n8 4279900716\n408 4278988093\n409 4282387520\n410 4281086730\n113 4279439131\n26 4288425286\n27 4281834544\n28 4281156764\n1008 4281175449\n1009 4287704473\n1010 4288123437\n165 4290285077\n214 4290285077\n1012 4289309097\n157 4282269246\n185 4279438110\n201 4279304198\n206 6452351\n23 4288425286\n24 4281834544\n25 4281156764\n1005 4281175449\n1006 4287704473\n1007 4288123437\n43 4290285077\n213 4290285077\n1011 4289309097\n156 4284374622\n184 4284760474\n200 4286580016\n207 6452351\n5 4282595615\n255 4282006074\n381 4284243036\n242 4285698734\n374 4291006865\n241 4287072135\n337 4294902015\n397 1718026239\n500 4281611316\n501 4279904597\n502 4283045713\n503 4283767338\n644 4285478667\n504 4282798615\n505 4280177176\n506 4279717715\n645 4278519045\n646 4281413937\n507 4282653956\n508 4279318310\n647 4278522162\n509 4280619318\n510 4280369416\n511 4281799188\n512 4281806354\n648 4278979596\n513 4282137660\n514 4280235615\n515 4283770976\n516 4284354083\n649 4286794266\n517 4283587101\n518 4280637726\n519 4280510308\n650 4279834905\n520 4281677109\n521 4280037981\n522 4283177043\n523 4283501598\n651 4286202129\n524 4282929944\n525 4280111896\n526 4280048987\n652 4279374354\n610 4282598211\n611 4280498785\n612 4284364910\n613 4285272105\n653 4287386403\n614 4284309795\n615 4281229092\n616 4281037166\n654 4280295456\n527 4294765736\n528 4289789096\n529 4292410536\n530 4289264636\n531 4289249532\n532 4294941595\n533 4287249440\n534 4285096000\n535 4286999845\n536 4284779296\n537 4280312971\n538 4282138696\n545 4291393084\n546 4281211760\n547 4289022080\n548 4283979864\n549 4278423833\n60 4294677428\n61 4286000236\n62 4285535776\n63 4281422692\n64 4279453971\n65 4290933876\n66 4288964945\n67 4287443217\n539 4294879426\n540 4291287551\n59 4292459398\n68 4285027412\n69 4284378740\n541 4282729797\n542 4280889652\n543 4280626222\n544 4280691759\n84 4288627520\n85 4282086045\n86 4287006342\n87 4294967295\n88 4285288236\n89 4290542725\n90 4286417852\n91 4286101891\n92 4286611584\n550 4284111450\n551 4284511606\n552 4285428606\n553 4283650899\n93 4289762148\n94 4289238101\n554 4284895028\n555 4286801474\n556 4286604354\n557 4287061832\n558 4287005522\n559 4283778870\n560 4283124555\n95 4285098087\n561 4281940280\n562 4282005816\n563 4291857541\n564 4293914345\n565 4287861390\n566 4283521391\n567 4281283649\n568 4287850317\n569 4285550911\n570 4289278254\n571 4286721836\n572 4283922077\n573 4282997364\n128 4287884048\n129 4292163365\n130 4292857625\n131 4285711851\n132 4281025487\n133 4292487384\n134 4281183248\n135 4293231135\n574 4285913831\n575 4285913831\n576 4285913831\n577 4285913831\n578 4285913831\n137 4293319347\n138 4289110154\n139 4293582733\n140 4292852314\n141 4289959785\n142 4286142771\n579 4291871900\n580 4289701770\n581 4292397668\n582 4291928888\n583 4291734909\n584 4286340668\n143 4294376703\n144 4286348412\n145 4283914330\n585 4281940281\n586 4284045657\n587 4280968580\n588 4283525435\n589 4285290010\n149 4286282362\n151 4284045400\n152 4284374365\n590 4291870339\n591 4285543454\n592 4283591007\n593 4287727218\n594 4289043594\n595 4288977801\n596 4292071360\n597 4289833368\n598 4287989614\n159 4284047977\n160 4282797135\n599 4281349690\n600 4285948484\n166 4291588876\n167 4292770317\n168 4291785741\n169 4292178946\n170 4293623042\n171 4292178946\n172 4293388013\n173 4284652540\n174 4283684096\n175 4293346413\n601 4286940043\n602 4280964581\n603 4281305600\n604 4286916416\n176 4294945604\n177 4292711483\n178 4291200308\n179 4287717671\n605 4278460021\n606 4278460021\n607 4278460021\n608 4288716897\n609 4285558852\n186 4285229931\n187 4281291665\n188 4286594449\n189 4289206591\n190 4289442611\n191 4282753847\n192 4282167980\n1025 4288828722\n1026 4280756007\n195 4288256378\n196 4289491041\n197 4284647578\n198 4287071297\n617 4284900945\n618 4286008900\n619 4282473062\n620 4285229108\n621 4285039619\n622 4283985923\n623 4282536962\n624 4292381209\n625 4283728909\n626 4280236504\n202 4294954558\n203 4294612750\n204 4294926080\n627 4291601203\n628 4291196171\n629 4290198016\n630 4284504612\n375 4289259775\n376 4289259775\n379 4289789814\n380 4289789814\n377 4294891351\n378 4294891351\n637 4285758849\n382 4285296753\n383 4284046429\n384 4284638566\n208 4291678675\n209 4290895033\n210 4293248719\n211 4290889673\n638 4286020477\n639 4285563247\n640 4286805627\n385 4284895793\n212 4291608181\n641 4285092098\n642 4285081090\n643 4285072643\n215 4289903841\n216 4282014565\n1001 4278331947\n1002 4282061570\n1003 4281607937\n1004 4281729592\n405 4282847244\n406 4281929775\n407 4282393891\n1013 4281159446\n1014 4283044977\n1015 4288504090\n1016 4281486204\n1017 4289471793\n655 4280288294\n656 4278459936\n657 4278389791\n658 4281074970\n659 4278720002\n660 4280552709\n661 4281473544\n662 4281534729";
}
}
Offline
Could I see an example of you colors and a real minimap? Or at least a world link and the result you get from it?
Offline
What the program produces:
World link: http://everybodyedits.com/games/PWEeCl4tQxbkI
Offline
Well, leave .jpg behind and never look back!
The JPEG format uses frequency spectrum reduction as compression. Which is not that visible on big images, but creates ugly artifacts along edges, as we can see here.
I would recommend you use the PNG format instead, since it doesn't create such thing. Also, it can handle transparency.
Also, don't forget to turn visibility ON when you give a link!
Offline
Well, leave .jpg behind and never look back!
It works much better now! However, there is a small problem with colors being slightly off still (I updated the code.) Could you help me with this too?
This is what it is supposed to look like:
This is what I'm getting:
The blocks are a similar color (they're both blue) but some are really cyan and others just regular.
World link: http://everybodyedits.com/games/PWc9u3pmFxa0I
Offline
The weird colors are the background one
^ This is the background of the spawn box (bottom left corner)
Try to do a distinction between the two (Background IDs are between 500 and 999 if I remember well)
Offline
Are you sure you add the backgrounds first before the foreground?
Here you have the bgcolor too, bgcolor = worlds.Contains("backgroundColor") ? worlds.GetUInt("backgroundColor") : 0;
Offline
a picturebox can hold a backgroundimage and a normal image, what i did was set all backgrounds on the background image.
if you can read this....good for you
Offline
a picturebox can hold a backgroundimage and a normal image, what i did was set all backgrounds on the background image.
This is what I do too. Use two bitmaps one for background and one for foreground and then add the background layer first and foreground later.
Offline
Pages: 1
[ Started around 1732806353.2858 - Generated in 0.104 seconds, 13 queries executed - Memory usage: 1.5 MiB (Peak: 1.65 MiB) ]