Daily Archives

Articles indexed Friday June 28 2013

Page 4/19 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • What benefits does a game design degree have for a hobby game programmer?

    - by sm4
    I am interested in studying game design, not because I want a job in the games industry, but because I am interested in the subject itself. I read the following questions, but they mostly deal with the effects on your career in game industry. Should I consider a graduate degree in game development? Game Development Degree vs Computer Science Degree First I thought a game development degree could be beneficial. But from the websites of colleges that offer such degrees, I feel like its more about basic programming with examples from games. This college offers game design degrees, for example. My question is, can I benefit from such a degree when I already have a degree in Computer Science, I already know programming, I'm already developing a game and finally, I have this site to help me when I get stuck?

    Read the article

  • Rotate sprite to face 3D camera

    - by omikun
    I am trying to rotate a sprite so it is always facing a 3D camera. shaders->setUniform("camera", gCamera.matrix()); glm::mat4 scale = glm::scale(glm::mat4(), glm::vec3(5e5, 5e5, 5e5)); glm::vec3 look = gCamera.position(); glm::vec3 right = glm::cross(gCamera.up(), look); glm::vec3 up = glm::cross(look, right); glm::mat4 newTransform = glm::lookAt(glm::vec3(0), gCamera.position(), up) * scale; shaders->setUniform("model", newTransform); In the vertex shader: gl_Position = camera * model * vec4(vert, 1); The object will track the camera if I move the camera up or down, but if I rotate the camera around it, it will rotate in the other direction so I end up seeing its front twice and its back twice as I rotate around it 360. What am I doing wrong?

    Read the article

  • OpenGL VertexBuffer won'e render in GLFW3

    - by sm81095
    So I have started to try to learn OpenGL, and I decided to use GLFW to assist in window creation. The problem is, since GLFW3 is so new, there are no tutorials on it yet and how to use it with modern OpenGL (3.3, specifically). Using the GLFW3 tutorial found on the website, which uses older OpenGL rendering (glBegin(GL_TRIANGLES), glVertex3f()), and such, I can get a triangle to render to the screen. The problem is, using new OpenGL, I can't get the same triangle to render to the screen. I am new to OpenGL, and GLFW3 is new to most people, so I may be completely missing something obvious, but here is my code: static const GLuint g_vertex_buffer_data[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f }; int main(void) { GLFWwindow* window; if(!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW."); return -1; } glfwWindowHint(GLFW_SAMPLES, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); window = glfwCreateWindow(800, 600, "Test Window", NULL, NULL); if(!window) { glfwTerminate(); fprintf(stderr, "Failed to create a GLFW window"); return -1; } glfwMakeContextCurrent(window); glewExperimental = GL_TRUE; GLenum err = glewInit(); if(err != GLEW_OK) { glfwTerminate(); fprintf(stderr, "Failed to initialize GLEW"); fprintf(stderr, (char*)glewGetErrorString(err)); return -1; } GLuint VertexArrayID; glGenVertexArrays(1, &VertexArrayID); glBindVertexArray(VertexArrayID); GLuint programID = LoadShaders("SimpleVertexShader.glsl", "SimpleFragmentShader.glsl"); GLuint vertexBuffer; glGenBuffers(1, &vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW); while(!glfwWindowShouldClose(window)) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(programID); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableVertexAttribArray(0); glfwSwapBuffers(window); glfwPollEvents(); } glDeleteBuffers(1, &vertexBuffer); glDeleteProgram(programID); glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); } I know it is not my shaders, they are super simple and I've checked them against GLFW 2.7 so I know that they work. I'm assuming that I've missed something crucial to using the OpenGL context with GLFW3, so any help locating the problem would be greatly appreciated.

    Read the article

  • Artist, Looking to lean how to program games, where do I start? [on hold]

    - by Christopher Hindson
    I have bean an artist for many years now I am very comfortable with using Photoshop and Flash but I want to learn how to but together my own games, I bean doing my own research into this and at the moment I am at little bit stuck on witch direction to go down. So my question is witch programming language should I learn? I have already bean looking into this what i understand is that Gamemaker with its built in language (GML) is one of the most friendly to people who are new to the game making world. I have played around with this program and was pretty happy with it but I want more also you can use Unity with language such as C and javascript and then games built with Java witch looks interesting. One more thing before you send your answer in at this moment in time I would only be able to make 2D game but 3D isn't out of the picture.

    Read the article

  • How can I compile SM 3.0 effects in D3D11 in slimdx?

    - by jacker
    var bytecode = ShaderBytecode.CompileFromFile("shaders\\testShader.fx", "fx_5_0", ShaderFlags.None, SlimDX.D3DCompiler.EffectFlags.None, null, null, out str); var effect = new SlimDX.Direct3D11.Effect(gpu.Device, bytecode); Works fine but if I try to use another shader model like 4.0 or 3.0 it throws an error on the new effect creation: E_FAIL: An undetermined error occurred (-2147467259) How do I compile older shaders? And I've read about device context but I can't find any information on how to use them to maintain DX9 compatibility.

    Read the article

  • How to manage a multiplayer asynchronous environment in a game

    - by Phil
    I'm working on a game where players can setup villages, which can contain defending units. Any of these units (each on their own tiles) can be set to "campaign" which means they are no longer defending but can now be used to attack other villages. And each unit on a tile can have up to a 100 health. So far so good. Oh and it's all asynchronous so even though the server will be aware that your village is being attacked, you won't be until the attack is over. The issue I'm struggling with, is the following situation. Let's say a unit on a tile is being attacked by a player from another village. The other player see's your village and is attacking your units. You don't know this is happening though, so you set your unit to campaign and off you go to attack another village, with the unit which itself is actually being attacked by this other player. The other player stops attacking your village and leaves your unit with say a health of 1, which is then saved to the server. You however have this same unit are attacking another village with it, but now you discover that even though it started off with a 100 health, now mysteriously it only has 1... Solutions? Ideas? Edit The simplest solutions are often the best. I referred to Clash of clans below, well after a bit more digging it seems that in CoC you can only attack players that are offline! ha, that almost solves the problem. I say almost because there's still the situation where a players village could be in the process of being attacked when they come back online, still need to address that. Edit 2 A solution to the "What happens when a player is attacking your village and you come online" issue, could be the attacking player just get's kicked out of the village at that point and just get's whatever they had won up to that point, it's a bit of a fudge but it might work.

    Read the article

  • Pathfinding results in false path costs that are too high

    - by user2144536
    I'm trying to implement pathfinding in a game I'm programming using this method. I'm implementing it with recursion but some of the values after the immediate circle of tiles around the player are way off. For some reason I cannot find the problem with it. This is a screen cap of the problem: The pathfinding values are displayed in the center of every tile. Clipped blocks are displayed with the value of 'c' because the values were too high and were covering up the next value. The red circle is the first value that is incorrect. The code below is the recursive method. //tileX is the coordinates of the current tile, val is the current pathfinding value, used[][] is a boolean //array to keep track of which tiles' values have already been assigned public void pathFind(int tileX, int tileY, int val, boolean[][] used) { //increment pathfinding value int curVal = val + 1; //set current tile to true if it hasn't been already used[tileX][tileY] = true; //booleans to know which tiles the recursive call needs to be used on boolean topLeftUsed = false, topUsed = false, topRightUsed = false, leftUsed = false, rightUsed = false, botomLeftUsed = false, botomUsed = false, botomRightUsed = false; //set value of top left tile if necessary if(tileX - 1 >= 0 && tileY - 1 >= 0) { //isClipped(int x, int y) returns true if the coordinates givin are in a tile that can't be walked through (IE walls) //occupied[][] is an array that keeps track of which tiles have an enemy in them // //if the tile is not clipped and not occupied set the pathfinding value if(isClipped((tileX - 1) * 50 + 25, (tileY - 1) * 50 + 25) == false && occupied[tileX - 1][tileY - 1] == false && !(used[tileX - 1][tileY - 1])) { pathFindingValues[tileX - 1][tileY - 1] = curVal; topLeftUsed = true; used[tileX - 1][tileY - 1] = true; } //if it is occupied set it to an arbitrary high number so enemies find alternate routes if the best is clogged if(occupied[tileX - 1][tileY - 1] == true) pathFindingValues[tileX - 1][tileY - 1] = 1000000000; //if it is clipped set it to an arbitrary higher number so enemies don't travel through walls if(isClipped((tileX - 1) * 50 + 25, (tileY - 1) * 50 + 25) == true) pathFindingValues[tileX - 1][tileY - 1] = 2000000000; } //top middle if(tileY - 1 >= 0 ) { if(isClipped(tileX * 50 + 25, (tileY - 1) * 50 + 25) == false && occupied[tileX][tileY - 1] == false && !(used[tileX][tileY - 1])) { pathFindingValues[tileX][tileY - 1] = curVal; topUsed = true; used[tileX][tileY - 1] = true; } if(occupied[tileX][tileY - 1] == true) pathFindingValues[tileX][tileY - 1] = 1000000000; if(isClipped(tileX * 50 + 25, (tileY - 1) * 50 + 25) == true) pathFindingValues[tileX][tileY - 1] = 2000000000; } //top right if(tileX + 1 <= used.length && tileY - 1 >= 0) { if(isClipped((tileX + 1) * 50 + 25, (tileY - 1) * 50 + 25) == false && occupied[tileX + 1][tileY - 1] == false && !(used[tileX + 1][tileY - 1])) { pathFindingValues[tileX + 1][tileY - 1] = curVal; topRightUsed = true; used[tileX + 1][tileY - 1] = true; } if(occupied[tileX + 1][tileY - 1] == true) pathFindingValues[tileX + 1][tileY - 1] = 1000000000; if(isClipped((tileX + 1) * 50 + 25, (tileY - 1) * 50 + 25) == true) pathFindingValues[tileX + 1][tileY - 1] = 2000000000; } //left if(tileX - 1 >= 0) { if(isClipped((tileX - 1) * 50 + 25, (tileY) * 50 + 25) == false && occupied[tileX - 1][tileY] == false && !(used[tileX - 1][tileY])) { pathFindingValues[tileX - 1][tileY] = curVal; leftUsed = true; used[tileX - 1][tileY] = true; } if(occupied[tileX - 1][tileY] == true) pathFindingValues[tileX - 1][tileY] = 1000000000; if(isClipped((tileX - 1) * 50 + 25, (tileY) * 50 + 25) == true) pathFindingValues[tileX - 1][tileY] = 2000000000; } //right if(tileX + 1 <= used.length) { if(isClipped((tileX + 1) * 50 + 25, (tileY) * 50 + 25) == false && occupied[tileX + 1][tileY] == false && !(used[tileX + 1][tileY])) { pathFindingValues[tileX + 1][tileY] = curVal; rightUsed = true; used[tileX + 1][tileY] = true; } if(occupied[tileX + 1][tileY] == true) pathFindingValues[tileX + 1][tileY] = 1000000000; if(isClipped((tileX + 1) * 50 + 25, (tileY) * 50 + 25) == true) pathFindingValues[tileX + 1][tileY] = 2000000000; } //botom left if(tileX - 1 >= 0 && tileY + 1 <= used[0].length) { if(isClipped((tileX - 1) * 50 + 25, (tileY + 1) * 50 + 25) == false && occupied[tileX - 1][tileY + 1] == false && !(used[tileX - 1][tileY + 1])) { pathFindingValues[tileX - 1][tileY + 1] = curVal; botomLeftUsed = true; used[tileX - 1][tileY + 1] = true; } if(occupied[tileX - 1][tileY + 1] == true) pathFindingValues[tileX - 1][tileY + 1] = 1000000000; if(isClipped((tileX - 1) * 50 + 25, (tileY + 1) * 50 + 25) == true) pathFindingValues[tileX - 1][tileY + 1] = 2000000000; } //botom middle if(tileY + 1 <= used[0].length) { if(isClipped((tileX) * 50 + 25, (tileY + 1) * 50 + 25) == false && occupied[tileX][tileY + 1] == false && !(used[tileX][tileY + 1])) { pathFindingValues[tileX][tileY + 1] = curVal; botomUsed = true; used[tileX][tileY + 1] = true; } if(occupied[tileX][tileY + 1] == true) pathFindingValues[tileX][tileY + 1] = 1000000000; if(isClipped((tileX) * 50 + 25, (tileY + 1) * 50 + 25) == true) pathFindingValues[tileX][tileY + 1] = 2000000000; } //botom right if(tileX + 1 <= used.length && tileY + 1 <= used[0].length) { if(isClipped((tileX + 1) * 50 + 25, (tileY + 1) * 50 + 25) == false && occupied[tileX + 1][tileY + 1] == false && !(used[tileX + 1][tileY + 1])) { pathFindingValues[tileX + 1][tileY + 1] = curVal; botomRightUsed = true; used[tileX + 1][tileY + 1] = true; } if(occupied[tileX + 1][tileY + 1] == true) pathFindingValues[tileX + 1][tileY + 1] = 1000000000; if(isClipped((tileX + 1) * 50 + 25, (tileY + 1) * 50 + 25) == true) pathFindingValues[tileX + 1][tileY + 1] = 2000000000; } //call the method on the tiles that need it if(tileX - 1 >= 0 && tileY - 1 >= 0 && topLeftUsed) pathFind(tileX - 1, tileY - 1, curVal, used); if(tileY - 1 >= 0 && topUsed) pathFind(tileX , tileY - 1, curVal, used); if(tileX + 1 <= used.length && tileY - 1 >= 0 && topRightUsed) pathFind(tileX + 1, tileY - 1, curVal, used); if(tileX - 1 >= 0 && leftUsed) pathFind(tileX - 1, tileY, curVal, used); if(tileX + 1 <= used.length && rightUsed) pathFind(tileX + 1, tileY, curVal, used); if(tileX - 1 >= 0 && tileY + 1 <= used[0].length && botomLeftUsed) pathFind(tileX - 1, tileY + 1, curVal, used); if(tileY + 1 <= used[0].length && botomUsed) pathFind(tileX, tileY + 1, curVal, used); if(tileX + 1 <= used.length && tileY + 1 <= used[0].length && botomRightUsed) pathFind(tileX + 1, tileY + 1, curVal, used); }

    Read the article

  • NullPointerException when setting adapter

    - by Sorin Grecu
    I'm trying to get the filenames in a folder inside a listview(that listview is inside a layout of a ViewPager) but i'm getting a NullPointerException and i can't figure what's wrong. public void citire() { ListView lv1 = (ListView) findViewById(R.id.lv1); myList = new ArrayList<String>(); File directory = Environment.getExternalStorageDirectory(); file = new File(directory + "/InterSRL"); File list[] = file.listFiles(); for (int i = 0; i < list.length; i++) { myList.add(list[i].getName()); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, myList); lv1.setAdapter(adapter); } I'm getting the error at lv1.setAdapter(adapter); 06-28 13:10:57.987: E/AndroidRuntime(30450): Caused by: java.lang.NullPointerException 06-28 13:10:57.987: E/AndroidRuntime(30450): at com.example.testlayout.Gestionare.citire(Gestionare.java:169) 06-28 13:10:57.987: E/AndroidRuntime(30450): at com.example.testlayout.Gestionare.onCreate(Gestionare.java:33) 06-28 13:10:57.987: E/AndroidRuntime(30450): at android.app.Activity.performCreate(Activity.java:5104) 06-28 13:10:57.987: E/AndroidRuntime(30450): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 06-28 13:10:57.987: E/AndroidRuntime(30450): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

    Read the article

  • Facebook,Android- How to get friends birthday from facebook

    - by Eriz
    I tried to goto lots of questions on this forum but could not find one useful so i decided to ask one myself. I want to pull the birthday's of all the friends in the users friend list. After going through a lot of stuff i found there are 2 ways to do that 1. Graph API 2. FQL Query So, my first question is , which one of them is better/easy to integrate in the app. Q2. http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/ is this tutorial useful for what i want to do. Q3. If i use Graph API/FQL Query , could you please give me a link which is helpful or a Code snippet Thanks In Advance, Eriz

    Read the article

  • Resultset (getter/setter class) object not deleting old values at 2nd Time execution in swin

    - by user2384525
    I have summarizeData() method and called so many time for value retrieve. but first time is working file but 2nd time execution value is increasing in HashMap. void summarizeData() { HashMap outerMap = new HashMap(); ArrayList list = new ArrayList(dataClass.getData()); for (int indx = 0; indx < list.size(); indx++) { System.out.println("indx : " + indx); Resultset rs = new Resultset(); rs = (Resultset) list.get(indx); if (rs != null) { int id = rs.getTestCaseNumber(); if (id > 0) { Object isExists = outerMap.get(id); if (isExists != null) { //System.out.println("found entry so updating"); Resultset inRs = new Resultset(); inRs = (Resultset) isExists; if (inRs != null) { int totExec = inRs.getTestExecution(); int totPass = inRs.getTestCasePass(); int totFail = inRs.getTestCaseFail(); // System.out.println("totE :" + totExec + " totP:" + totPass + " totF:" + totFail); int newRsStat = rs.getTestCasePass(); if (newRsStat == 1) { totPass++; inRs.setTestCasePass(totPass); } else { totFail++; inRs.setTestCaseFail(totFail); } totExec++; // System.out.println("id : "+id+" totPass: "+totPass+" totFail:"+totFail); // System.out.println("key : " + id + " val : " + inRs.getTestCaseNumber() + " " + inRs.getTestCasePass() + " " + inRs.getTestCaseFail()); inRs.setTestExecution(totExec); outerMap.put(id, inRs); } } else { // System.out.println("not exist so new entry" + " totE:" + rs.getTestExecution() + " totP:" + rs.getTestCasePass() + " totF:" + rs.getTestCaseFail()); outerMap.put(id, rs); } } } else { System.out.println("rs null"); } } Output at 1st Execution: indx : 0 indx : 1 indx : 2 indx : 3 indx : 4 indx : 5 indx : 6 indx : 7 indx : 8 indx : 9 indx : 10 totE :1 totP:1 totF:0 indx : 11 totE :1 totP:1 totF:0 indx : 12 totE :1 totP:1 totF:0 indx : 13 totE :1 totP:1 totF:0 indx : 14 totE :1 totP:1 totF:0 indx : 15 totE :1 totP:1 totF:0 indx : 16 totE :1 totP:1 totF:0 indx : 17 totE :1 totP:1 totF:0 indx : 18 totE :1 totP:1 totF:0 indx : 19 totE :1 totP:1 totF:0 Output at 2nd Execution: indx : 0 indx : 1 indx : 2 indx : 3 indx : 4 indx : 5 indx : 6 indx : 7 indx : 8 indx : 9 indx : 10 totE :2 totP:2 totF:0 indx : 11 totE :2 totP:2 totF:0 indx : 12 totE :2 totP:2 totF:0 indx : 13 totE :2 totP:2 totF:0 indx : 14 totE :2 totP:2 totF:0 indx : 15 totE :2 totP:2 totF:0 indx : 16 totE :2 totP:2 totF:0 indx : 17 totE :2 totP:2 totF:0 indx : 18 totE :2 totP:2 totF:0 indx : 19 totE :2 totP:2 totF:0 while i required same output on every execution.

    Read the article

  • Set z-index with javascript setTimeout()

    - by user2266261
    What I'm trying to do is to have 4 expandable divs overlapping each other with transition set in css for 0.6s. Because the expanding lasts for 0.6s I'd like to have the expanded div lose it's higher z-index after it's done collapsing, otherwise it looks silly. However, it doesn't work, the z-index remains unchanged. It's probably somethings stupid, but I just can't find it. Thanks! <div class="wrapper" style="position: relative;"> <div id="one" style="position: absolute;" onmouseover=" this.style.height='250px'; this.style.zIndex='1'; " onmouseout=" this.style.height='50px'; setTimeout(function() {this.style.zIndex='0';},600); ">blahblahblahblah</div> <div id="two" style="position: absolute;" onmouseover=" this.style.height='250px'; this.style.zIndex='1'; " onmouseout=" this.style.height='50px'; setTimeout(function() {this.style.zIndex='0';},600); ">blahblahblahblah</div> </div>

    Read the article

  • Nested CheckBox in Java

    - by Shailesh Ahuja
    I want to create a nested checkbox list. If the user checks the main item, all the sub-items under and get checked. If the user checks some of the sub-items, then a blue square appears inside the main items checkbox. It should look something like this. How do I do that in Java 1.6? Can I use swing or any external library? I would like to choose the easiest and the fastest way to achieve this? My aim is to create only 1 level of nesting.

    Read the article

  • Java/MySQL: Working with data in classes

    - by skiwi
    What is the best way to deal with accessing/modifying tables in a database? I have read about the Data Access Object approach, but none of the resources I have found so far indicate a clear implementation of it. So assume you have a database with a table called accounts that has columns id, name, password and email. How would you properly access it within Java? I mean most people know how to do SQL statements, but that is not really the point. I hope people here can be of help. Regards.

    Read the article

  • Convert PDF to Image Batch

    - by tro
    I am working on a solution where I can convert pdf files to images. I am using the following example from codeproject: http://www.codeproject.com/Articles/317700/Convert-a-PDF-into-a-series-of-images-using-Csharp?msg=4134859#xx4134859xx now I tried with the following code to generate from more then 1000 pdf files new images: using Cyotek.GhostScript; using Cyotek.GhostScript.PdfConversion; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RefClass_PDF2Image { class Program { static void Main(string[] args) { string outputPath = Properties.Settings.Default.outputPath; string pdfPath = Properties.Settings.Default.pdfPath; if (!Directory.Exists(outputPath)) { Console.WriteLine("Der angegebene Pfad " + outputPath + " für den Export wurde nicht gefunden. Bitte ändern Sie den Pfad (outputPath) in der App.Config Datei."); return; } else { Console.WriteLine("Output Pfad: " + outputPath + " gefunden."); } if (!Directory.Exists(pdfPath)) { Console.WriteLine("Der angegebene Pfad " + pdfPath + " zu den PDF Zeichnungen wurde nicht gefunden. Bitte ändern Sie den Pfad (pdfPath) in der App.Config Datei."); return; } else { Console.WriteLine("PDF Pfad: " + pdfPath + " gefunden."); } Pdf2ImageSettings settings = GetPDFSettings(); DateTime start = DateTime.Now; TimeSpan span; Console.WriteLine(""); Console.WriteLine("Extraktion der PDF Zeichnungen wird gestartet: " + start.ToShortTimeString()); Console.WriteLine(""); DirectoryInfo diretoryInfo = new DirectoryInfo(pdfPath); DirectoryInfo[] directories = diretoryInfo.GetDirectories(); Console.WriteLine(""); Console.WriteLine("Es wurden " + directories.Length + " verschiedende Verzeichnisse gefunden."); Console.WriteLine(""); List<string> filenamesPDF = Directory.GetFiles(pdfPath, "*.pdf*", SearchOption.AllDirectories).Select(x => Path.GetFullPath(x)).ToList(); List<string> filenamesOutput = Directory.GetFiles(outputPath, "*.*", SearchOption.AllDirectories).Select(x => Path.GetFullPath(x)).ToList(); Console.WriteLine(""); Console.WriteLine("Es wurden " + filenamesPDF.Count + " verschiedende PDF Zeichnungen gefunden."); Console.WriteLine(""); List<string> newFileNames = new List<string>(); int cutLength = pdfPath.Length; for (int i = 0; i < filenamesPDF.Count; i++) { string temp = filenamesPDF[i].Remove(0, cutLength); temp = outputPath + temp; temp = temp.Replace("pdf", "jpg"); newFileNames.Add(temp); } for (int i = 0; i < filenamesPDF.Count; i++) { FileInfo fi = new FileInfo(newFileNames[i]); if (!fi.Exists) { if (!Directory.Exists(fi.DirectoryName)) { Directory.CreateDirectory(fi.DirectoryName); } Bitmap firstPage = new Pdf2Image(filenamesPDF[i], settings).GetImage(); firstPage.Save(newFileNames[i], System.Drawing.Imaging.ImageFormat.Jpeg); firstPage.Dispose(); } //if (i % 20 == 0) //{ // GC.Collect(); // GC.WaitForPendingFinalizers(); //} } Console.ReadLine(); } private static Pdf2ImageSettings GetPDFSettings() { Pdf2ImageSettings settings; settings = new Pdf2ImageSettings(); settings.AntiAliasMode = AntiAliasMode.Medium; settings.Dpi = 150; settings.GridFitMode = GridFitMode.Topological; settings.ImageFormat = ImageFormat.Png24; settings.TrimMode = PdfTrimMode.CropBox; return settings; } } } unfortunately, I always get in the Pdf2Image.cs an out of memory exception. here the code: public Bitmap GetImage(int pageNumber) { Bitmap result; string workFile; //if (pageNumber < 1 || pageNumber > this.PageCount) // throw new ArgumentException("Page number is out of bounds", "pageNumber"); if (pageNumber < 1) throw new ArgumentException("Page number is out of bounds", "pageNumber"); workFile = Path.GetTempFileName(); try { this.ConvertPdfPageToImage(workFile, pageNumber); using (FileStream stream = new FileStream(workFile, FileMode.Open, FileAccess.Read)) { result = new Bitmap(stream); // --->>> here is the out of memory exception stream.Close(); stream.Dispose(); } } finally { File.Delete(workFile); } return result; } how can I fix that to avoid this exception? thanks for any help, tro

    Read the article

  • linker error in simple program: multiple definition of function

    - by BillyJean
    My function test is added to two different .cpp-files and the functions are private to their respective files as shown below test1.cpp #include <iostream> using namespace std; void test() { cout << "test" << endl; } test2.cpp #include <iostream> using namespace std; void test() { cout << "test" << endl; } main.cpp #include <iostream> using namespace std; int main() { return 0; } During linking I get the error multiple definition of test() - but how is that possible, considering that the two files have their own private scope!? I could understand it if I included the function prototype in each .cpp-files' corresponding header, but there is no such thing in this example.

    Read the article

  • Where should I store my App specific config files in WPF

    - by Akash Deshpande
    Background : I have some Application Data. i.e. the Database, come important config files. This data is vital for the application to start else it is exited. Problem : Where should I store this data. i.e in which folder and where. Right Now (This is wrong) it is stored in a folder in Debug/App_Data. But is causing issues in git and when we publish the App the data is not found. So where can we store this folder ? Present Structure is "WpfApplication2\WpfApplication2\bin\Debug" These Files need to be present when the app is started. So they need to be a part of the app itself.

    Read the article

  • How to create Ror style Restful routing in Asp.net MVC Web Api

    - by Jas
    How to configure routing in asp.net web api, to that I can code for the following actions in my ApiController inherited class? |======================================================================================| |Http Verb| Path | Action | Used for | |======================================================================================| | GET | /photos | index | display a list of all photos | | GET | /photos/new | new | return an HTML form for creating a new photo | | POST | /photos/ | create | create a new photo | | GET | /photos/:id | show | display a specific photo | | GET | /photos/:id/edit | edit | return an HTML form for editing a photo | | PUT | /photos/:id | update | update a specific photo | | DELETE | /photos/:id | destroy | delete a specific photo |

    Read the article

  • PHP - Get dates of next 5 weekdays?

    - by Dan
    I'm trying to create an array of the next 5 working week days (Monday - Friday, excluding today). I know the working week varies around the world but this is not important for what I am trying to do. So, for example, if today is a Wednesday, I want the dates for Thursday and Friday of the current week and Monday, Tuesday and Wednesday of the following week. I thought this would work: $dates = array(); for ($i = 1; $ < 6; $i ++) { $dates[] = date('Y-m-d', strtotime('+ '.$i.' weekday')); } But for today, it is giving me: Monday 1st Tuesday 2nd Wednesday 3rd Thursday 4th Sunday 7th! Any advice appreciated. Thanks

    Read the article

  • Returning control codes as JSON to a jquery ajax json call

    - by Graham
    I want to know if it is possible to return ascii control codes in JSON format from classic ASP to a jQuery ajax call. This is my jQuery call: $.ajax({ url: "/jsontest.asp", type: "POST", cache: false, dataType: "json", complete: function(data) { var o = $.parseJSON(data.responseText.toString()); }, error: function(data1, data2) { alert("There has been an error - please try again"); } }); This is my called page: {"val1":123,"val2","abcdef"} The above works fine, but if I change my called page to include ascii character 31 (1F) like so: {"val1":123,"val2","abc\x1Fdef"} then I get the alert in my error function. Can this be done, and if so, how please. Note: I'm using jQuery 1.7.1 and both IIS 6 and IIS 7 I have tried: \x1f, %1f, and \u001f

    Read the article

  • Combine regular expressions for splitting camelCase string into words

    - by stou
    I managed to implement a function that converts camel case to words, by using the solution suggested by @ridgerunner in this question: Split camelCase word into words with php preg_match (Regular Expression) However, I want to also handle embedded abreviations like this: 'hasABREVIATIONEmbedded' translates to 'Has ABREVIATION Embedded' I came up with this solution: <?php function camelCaseToWords($camelCaseStr) { // Convert: "TestASAPTestMore" to "TestASAP TestMore" $abreviationsPattern = '/' . // Match position between UPPERCASE "words" '(?<=[A-Z])' . // Position is after group of uppercase, '(?=[A-Z][a-z])' . // and before group of lowercase letters, except the last upper case letter in the group. '/x'; $arr = preg_split($abreviationsPattern, $camelCaseStr); $str = implode(' ', $arr); // Convert "TestASAP TestMore" to "Test ASAP Test More" $camelCasePattern = '/' . // Match position between camelCase "words". '(?<=[a-z])' . // Position is after a lowercase, '(?=[A-Z])' . // and before an uppercase letter. '/x'; $arr = preg_split($camelCasePattern, $str); $str = implode(' ', $arr); $str = ucfirst(trim($str)); return $str; } $inputs = array( 'oneTwoThreeFour', 'StartsWithCap', 'hasConsecutiveCAPS', 'ALLCAPS', 'ALL_CAPS_AND_UNDERSCORES', 'hasABREVIATIONEmbedded', ); echo "INPUT"; foreach($inputs as $val) { echo "'" . $val . "' translates to '" . camelCaseToWords($val). "'\n"; } The output is: INPUT'oneTwoThreeFour' translates to 'One Two Three Four' 'StartsWithCap' translates to 'Starts With Cap' 'hasConsecutiveCAPS' translates to 'Has Consecutive CAPS' 'ALLCAPS' translates to 'ALLCAPS' 'ALL_CAPS_AND_UNDERSCORES' translates to 'ALL_CAPS_AND_UNDERSCORES' 'hasABREVIATIONEmbedded' translates to 'Has ABREVIATION Embedded' It works as intended. My question is: Can I combine the 2 regular expressions $abreviationsPattern and camelCasePattern so i can avoid running the preg_split() function twice?

    Read the article

  • NavigationBar text colour not changing?

    - by Jeff
    In my tabbar application I am adding Navigation controller in each tab. Suppose the selected index is 0 when I opening the app.In my 3rd tab(selected index=2) I want to change the text colour of navigationbar title.And I am using the code [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor greenColor],UITextAttributeTextColor,nil]]; But its not changing the text color of Index 0 and 2.Colour of index 1 will change only if that tab was not clicked before changing the colour by using the above code. I don't know whats is the issue ? Any help/code will be appreciable.

    Read the article

  • querySelectorAll is not finding dynamically added elements with custom attribute

    - by Exception
    I am creating two way binding between JS Object and UI in below fiddle, code is big to post Please check http://jsfiddle.net/bpH6Z/20/ I am using the code like below var elements = document.querySelectorAll("[" + data_attr + "] *[bd='" + prop_name + "']"); I have mentioned the problem line in big comments, can be identified easily. My problem is I am adding elements to binded dynamicaly using JS, when I change the value in UI, the same value is not reflected in other places. The problem is querySelectorAll is faling to find elements with same attribute. It is finding only first occurrence. Please look into the issue.

    Read the article

  • "import numpy" tries to load my own package

    - by Sebastian
    I have a python (2.7) project containing my own packages util and operator (and so forth). I read about relative imports, but perhaps I didn't understand. I have the following directory structure: top-dir/ util/__init__.py (empty) util/ua.py util/ub.py operator/__init__.py ... test/test1.py The test1.py file contains #!/usr/bin/env python2 from __future__ import absolute_import # removing this line dosn't change anything. It's default functionality in python2.7 I guess import numpy as np It's fine when I execute test1.py inside the test/ folder. But when I move to the top-dir/ the import numpy wants to include my own util package: Traceback (most recent call last): File "tests/laplace_2d_square.py", line 4, in <module> import numpy as np File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module> import add_newdocs File "/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module> from numpy.lib import add_newdoc File "/usr/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module> from type_check import * File "/usr/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module> import numpy.core.numeric as _nx File "/usr/lib/python2.7/site-packages/numpy/core/__init__.py", line 45, in <module> from numpy.testing import Tester File "/usr/lib/python2.7/site-packages/numpy/testing/__init__.py", line 8, in <module> from unittest import TestCase File "/usr/lib/python2.7/unittest/__init__.py", line 58, in <module> from .result import TestResult File "/usr/lib/python2.7/unittest/result.py", line 9, in <module> from . import util File "/usr/lib/python2.7/unittest/util.py", line 2, in <module> from collections import namedtuple, OrderedDict File "/usr/lib/python2.7/collections.py", line 9, in <module> from operator import itemgetter as _itemgetter, eq as _eq ImportError: cannot import name itemgetter The troublesome line is either from . import util or perhaps from operator import itemgetter as _itemgetter, eq as _eq What can I do?

    Read the article

  • function to find common rows between more than two data frames in R

    - by biohazard
    I have 4 data frames, and would like to find the rows whose values in a certain column do not exist in any of the other data frames. I wrote this function: #function to test presence of $Name in 3 other datasets common <- function(a, b, c, d) { is.B <- is.numeric(a$Name %in% b$Name) == 1 is.C <- is.numeric(a$Name %in% c$Name) == 1 is.D <- is.numeric(a$Name %in% d$Name) == 1 t <- as.numeric(is.B & is.C & is.D) t } However, the output is always t = 0. This means that it tells me that there are no unique rows in any data sets, even though the datas frames have very different numbers of rows. Since there are no duplicate rows in any of the data frames, I should be getting t = 1 for at least some rows in the biggest dataset. Can someone figure out what I got wrong?

    Read the article

  • Parsing Strings ( .crt files )

    - by user1661521
    Base Knowledge : I have a .crt file ( certification authoritie file ) and he is composed of many fields but in one line that resumes this question i have this : Certificate: ...(alot of stuff before)... Subject: C=US, ST=Maryland, L=Pasadena, O=Brent Baccala, OU=FreeSoft, CN=www.freesoft.org/[email protected] Subject Public Key Info: ...(alot of stuff after) and i need to parse the file to populate a .csv file and i have that done the problem that i need help is, i need to get the field: CN=www.fresoft.org but when i get this kind of CN=...(Value instead of the ...) with alot of slashes i get a error in the parsing like the raw string is: CN=foo/bar/the/hell/emailAddress=blablabla and i need only: foo/bar/the/hell and for a moment i got that in the correct column but when i dont have the emailAddress something just fail in my parsing and i then get in my CN .csv column the information wrong instead of |CN| foo/bar/the/hell i get: |CN| OU=FreeSoft, foo/bar/the/hell. I have this code doing the CN parsing: #!/bin/bash subject_line=$(echo $cert | grep -o "Subject:.*Subject Public Key Info") cn=$(echo $subject_line | grep -o "CN=.*" ) if [ $(echo $cn | grep -c ".*email.*") -gt 0 ]; then end_cn=$(echo $cn | grep -b -o emailAddress) end_cn_idx=$(echo $end_cn | grep -o .*:) final_end_cn=${end_cn_idx:0:-1} common_name=${cn:3:$final_end_cn-4} echo $common_name else end_cn=$(echo $cn | grep -b -o "Subject Public Key Info") end_cn_idx=$(echo $end_cn | grep -o .*:) final_end_cn=${end_cn_idx:0:-1} common_name=${cn:3:$final_end_cn-5} echo $common_name fi

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >