Search Results

Search found 20316 results on 813 pages for 'image manipulation'.

Page 10/813 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • String Manipulation: Splitting Delimitted Data

    - by Milli Szabo
    I need to split some info from a asterisk delimitted data. Data Format: NAME*ADRESS LINE1*ADDRESS LINE2 Rules: 1. Name should be always present 2. Address Line 1 and 2 might not be 3. There should be always three asterisks. Samples: MR JONES A ORTEGA*ADDRESS 1*ADDRESS2* Name: MR JONES A ORTEGA Address Line1: ADDRESS 1 Address Line2: ADDRESS 2 A PAUL*ADDR1** Name: A PAUL Address Line1: ADDR1 Address Line2: Not Given My algo is: 1. Iterate through the characters in the line 2. Store all chars in a temp variables until first * is found. Reject the data if no char is found before first occurence of asterisk. If some chars found, use it as the name. 3. Same as step 2 for finding address line 1 and 2 except that this won't reject the data if no char is found My algo looks ugly. The code looks uglier. Spliting using //* doesn't work either since name can be replaced with address line 1 if the data was *Address 1*Address2. Any suggestion?

    Read the article

  • String manipulation in Linux kernel module

    - by user577066
    I am having a hard time in manipulating strings while writing module for linux. My problem is that I have a int Array[10] with different values in it. I need to produce a string to be able send to the buffer in my_read procedure. If my array is {0,1,112,20,4,0,0,0,0,0} then my output should be: 0:(0) 1:-(1) 2:-------------------------------------------------------------------------------------------------------(112) 3:--------------------(20) 4:----(4) 5:(0) 6:(0) 7:(0) 8:(0) 9:(0) when I try to place the above strings in char[] arrays some how weird characters end up there here is the code int my_read (char *page, char **start, off_t off, int count, int *eof, void *data) { int len; if (off > 0){ *eof =1; return 0; } /* get process tree */ int task_dep=0; /* depth of a task from INIT*/ get_task_tree(&init_task,task_dep); char tmp[1024]; char A[ProcPerDepth[0]],B[ProcPerDepth[1]],C[ProcPerDepth[2]],D[ProcPerDepth[3]],E[ProcPerDepth[4]],F[ProcPerDepth[5]],G[ProcPerDepth[6]],H[ProcPerDepth[7]],I[ProcPerDepth[8]],J[ProcPerDepth[9]]; int i=0; for (i=0;i<1024;i++){ tmp[i]='\0';} memset(A, '\0', sizeof(A));memset(B, '\0', sizeof(B));memset(C, '\0', sizeof(C)); memset(D, '\0', sizeof(D));memset(E, '\0', sizeof(E));memset(F, '\0', sizeof(F)); memset(G, '\0', sizeof(G));memset(H, '\0', sizeof(H));memset(I, '\0', sizeof(I));memset(J, '\0', sizeof(J)); printk("A:%s\nB:%s\nC:%s\nD:%s\nE:%s\nF:%s\nG:%s\nH:%s\nI:%s\nJ:%s\n",A,B,C,D,E,F,G,H,I,J); memset(A,'-',sizeof(A)); memset(B,'-',sizeof(B)); memset(C,'-',sizeof(C)); memset(D,'-',sizeof(D)); memset(E,'-',sizeof(E)); memset(F,'-',sizeof(F)); memset(G,'-',sizeof(G)); memset(H,'-',sizeof(H)); memset(I,'-',sizeof(I)); memset(J,'-',sizeof(J)); printk("A:%s\nB:%s\nC:%s\nD:%s\nE:%s\nF:%s\nG:%s\nH:%s\nI:%s\nJ:%\n",A,B,C,D,E,F,G,H,I,J); len = sprintf(page,"0:%s(%d)\n1:%s(%d)\n2:%s(%d)\n3:%s(%d)\n4:%s(%d)\n5:%s(%d)\n6:%s(%d)\n7:%s(%d)\n8:%s(%d)\n9:%s(%d)\n",A,ProcPerDepth[0],B,ProcPerDepth[1],C,ProcPerDepth[2],D,ProcPerDepth[3],E,ProcPerDepth[4],F,ProcPerDepth[5],G,ProcPerDepth[6],H,ProcPerDepth[7],I,ProcPerDepth[8],J,ProcPerDepth[9]); return len; }

    Read the article

  • Performance intensive string splitting and manipulation in java

    - by juhanic
    What is the most efficient way to split a string by a very simple separator? Some background: I am porting a function I wrote in C with a bunch of pointer arithmetic to java and it is incredibly slow(After some optimisation still 5* slower). Having profiled it, it turns out a lot of that overhead is in String.split The function in question takes a host name or ip address and makes it generic: 123.123.123.123-*.123.123.123 a.b.c.example.com-*.example.com This can be run over several million items on a regular basis, so performance is an issue.

    Read the article

  • C++ String manipulation isn't making sense to me...

    - by Andrew Bolster
    I am trying some of the Stanford SEE courses online to learn some new languages; this particular assignment has to do with removing substrings from strings. What I've got so far is below, but if text = "hello hello" and remove ="el", it gets stuck in a loop, but if i change text to text = "hello hllo", it works, making me think I'm doing something obviously stupid. There is a stipulation in the assignment not to modify the incoming strings, and instead to return a new string. string CensorString1(string text, string remove){ string returned; size_t found=0, lastfound=0; found = (text.substr(lastfound,text.size())).find(remove); while (string::npos != found ){ returned += text.substr(lastfound,found); lastfound = found + remove.size(); found = (text.substr(lastfound,text.size())).find(remove); } returned += text.substr(lastfound,found); return returned; } Guidance would be appreciated :-) Thanks

    Read the article

  • Python 2.7 list of lists manipulation functionality

    - by user3688163
    I am trying to perform several operations on the myList list of lists below and am having some trouble figuring it out. I am very new to Python. myList = [ ['Issue Id','1.Completeness for OTC','Break',3275,33,33725102303,296384802,20140107], ['Issue Id','2.Validity check1 for OTC','Break',3308,0,34021487105,0,20140107], ['Issue Id','3.Validity check2 for OTC','Break',3308,0,34021487105,0,20140107], ['Issue Id','4.Completeness for RST','Break',73376,1,8.24931E+11,44690130,20140107], ['Issue Id','5.Validity check1 for RST','Break',73377,0,8.24976E+11,0,20140107], ['Liquidity','1. OTC - Null','Break',7821 0,2.28291E+11,0,20140110], ['Liquidity','2. OTC - Unmapped','Break',7778,43,2.27712E+11,579021732.8,20140110], ['Liquidity','3. RST - Null','Break',335120,0,1.01425E+12,0,20140110], ['Liquidity','4. RST - Unmapped','Break',334608,512,1.01351E+12,735465433.1,20140110], ['Liquidity','5. RST - Valid','Break',335120,0,1.01425E+12,0,20140110], ['Issue Id','1.Completeness for OTC','Break',3292,33,32397924450,306203929,20140110], ['Issue Id','2.Validity check1 for OTC','Break',3325,0,32704128379,0,20140110], ['Issue Id','3.Validity check2 for OTC','Break',3325,0,32704128379,0,20140110], ['Issue Id','4.Completeness for RST','Break',73594,3,8.5352E+11,69614602,20140110], ['Issue Id','5.Validity check1 for RST','Break',73597,0,8.5359E+11,0,20140110], ['Unlinked Silver ID','DQ','Break',3201318,176,20000000,54974.33386,20140101], ['Missing GCI','DQ','Break',3201336,158,68000000,49351.9588,20140101], ['Missing Book','DQ Break',3192720,8774,3001000000,2740595.484,20140101], ['Matured Trades','DQ','Break',3201006,488,1371000000,152428.8348,20140101], ['Illiquid Trades','1.Completeness Check for range','Break',43122,47,88597695671,54399061.43,20140107], ['Illiquid Trades','2.Completeness Check for non','Break',39033,0,79133622401,0,20140107] ] I am trying to get the result below but do not know how to do so: newList = [ ['Issue Id','1.Completeness for OTC:2.Validity check1 for OTC:3.Validity check2 for OTC','Break',3275,33,33725102303,296384802,20140107], ['Issue Id','4.Completeness for RST:5.Validity check1 for RST','Break',73376,1,8.24931E+11,44690130,20140107], ['Liquidity','1. OTC - Null','Break:2. OTC - Unmapped','Break',7821 0,2.28291E+11,0,20140110], ['Liquidity','3. RST - Null:4. RST - Unmapped:5. RST - Valid','Break',335120,0,1.01425E+12,0,20140110], ['Issue Id','1.Completeness for OTC:2.Validity check1 for OTC:3.Validity check2 for OTC','Break',3292,33,32397924450,306203929,20140110], ['Issue Id','4.Completeness for RST:5. RST - Valid','Break',73594,3,8.5352E+11,69614602,20140110], ['Unlinked Silver ID','DQ','Break',3201318,176,20000000,54974.33386,20140101], ['Missing GCI','DQ','Break',3201336,158,68000000,49351.9588,20140101], ['Missing Book','DQ Break',3192720,8774,3001000000,2740595.484,20140101], ['Matured Trades','DQ','Break',3201006,488,1371000000,152428.8348,20140101], ['Illiquid Trades','1.Completeness Check for range','Break',43122,47,88597695671,54399061.43,20140107], ['Illiquid Trades','2.Completeness Check for non','Break',39033,0,79133622401,0,20140107] ] Rules to create newList. Create a new list in the newList list of lists if the values in the lists meet the following conditions: multiple lists that match on `myList[i][0]` and `myList[i][7]` but with have (1) sums of `myList[i][3]` and `myList[i][4]` and (2) sums of `myList[i][5]` and `myList[i][6]` that are different from each other are just listed as is in newList if multiple lists match on both `myList[i][0]` (this is the type) and `myList[i][7]` (this is the date) are the same then create a new list for each set of lists with mathcing `myList[i][0]` and `myList[i][7]` that have (1) sums of `myList[i][3]` and `myList[i][4]` and (2) sums of `myList[i][5]` and `myList[i][6]` that are different from the other lists with mathcing `myList[i][0]` and `myList[i][7]`. I also am trying to concatenate `myList[i][1]` separated by a ':' for all those lists with matching `myList[i][0]` and `myList[i][7]` and with sums of `myList[i][3]` + `myList[i][4]` and `myList[i][5]` + `myList[i][6]` that match. So essentially for this case only those lists in `myList` with sums of `myList[i][3]` + `myList[i][4]` and `myList[i][5]` + `myList[i][6]` are different from the other lists are then listed in newList. The above newList illustrates these results I am trying to achieve. If anyone has any ideas how to do this they would be greatly appreciated. Thank you!

    Read the article

  • Standard (cross-platform) way for bit manipulation

    - by Kiril Kirov
    As are are different binary representation of the numbers (for example, take big/little endian), is this cross-platform: some_unsigned_type variable = some_number; // set n-th bit, starting from 1, // right-to-left (least significant-to most significant) variable |= ( 1 << ( n - 1 ) ); // clear the same bit: variable &= ~( 1 << ( n - 1 ) ); In other words, does the compiler always take care of the different binary representation of the unsigned numbers, or it's platform-specific? And what if variable is signed integral type (for example, int) and its value is zero positive negative? What does the Standard say about this? P.S. And, yes, I'm interesting in both - C and C++, please don't tell me they are different languages, because I know this :) I can paste real example, if needed, but the post will become too long

    Read the article

  • Java File manipulation

    - by user69514
    So I have an application with a JFileChooser from which I select a file to read. Then I change some words and write a new file. The problem that I am having is that when I write the new file it's saved in the project directory. How do I save it in the same directory as the file that I chose using the JFileChooser. Note: I don't want to use the JFileChooser to choose the location. I just need to save the file in the same directory as the original file that I read.

    Read the article

  • Updating a backup image (.wim and/or Acronis .tib)

    - by Backdraft
    Anyways, I've got a Windows 7 installation that I want to make a generalized backup image of so I can use it for future installs on not only my desktop from which the image is to be derived from, but also other systems with dissimilar hardware. Therefore I've arrived at either 2 options, using either sysprep/imagx from WAIK (guide here), or the simpler Acronis True Image w/ their Universal Restore addon. Of course, they create distinct image file types, .wim and .tib respectively. What I'd like to do is to periodically update this image, say with Windows Updates, by booting it to either a physical partition or using virtualization (VirtualBox/VMWare), perform the updates, and save the updated .wim or .tib image file again. What's the simplest way I could do this? Another question is, I created this generalized backup image on a 500GB Seagate 7200RPM HDD. Say I get an SSD as an OS drive in the future, can I just deploy this backup image to the SSD normally, or are there any potential problems to be aware/avoid (ie. is it best to completely reinstall the OS on the SSD from scratch, or can I use the image created on the normal HDD with no issue)? Thanks and Happy Holidays.

    Read the article

  • Downloading error "Could not retrieve the required disk image "

    - by Freed Ahmad
    When I try to download Ubuntu 12.04 using the Windows installer (Wubi) through a proxy server which requires proxy authentication, after I choose the Ubuntu installation size, username and password, when I click the Install button, I get this error: An error occurred: Could not retrieve the required disk image files For more information, please see the log file: c:\users\(myusername)\appdata\local\temp\wubi-12.04-rev266.log The log file says: proxy authentication error How can I solve this problem?

    Read the article

  • Image hotlinking providers?

    - by Josh
    I use a lot of images in my wordpress and due to hosting restrictions I need to host the images somewhere else and hotlink them in my blog posts. So I am looking for some reliable image host which provides free hotlinking service. The Google Picasa would be best, but I think they do not allow hotlinking. PS. I'm not looking for hosts like tinypic or imgshack, I'm looking for some websites which provides powerful features to oranize images (eg. albums etc).

    Read the article

  • Rotate and Save Image - C#

    - by Taylor
    Hello, I'm trying to rotate and save an image, along with returning a BitmapSource. I pass in the rotation value (90 or -90) and the full path to the image I want to rotate to the method shown here. It works fine if I start and stop my application between calling this method. however, if the application calls rotate multiple times the rotate only happens once. I know the original image must be cached in memory, because if I pass values 90, 180, 270 I see the rotations work. I want to be able to pass in a value of 90 or -90 and have that rotate and save the original image. How can I make the rotate work for each call? Is there a way to clear the cached value of the image? If I don't set the BitmapCacheOption to OnLoad, I am unable to transform and save the image since the image is "being used by another process". public BitmapImage Rotate(int val, string path) { //create a new image from existing file. Image image = new Image(); BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.CacheOption = BitmapCacheOption.OnLoad; logo.UriSource = new Uri(path); logo.EndInit(); image.Source = logo; BitmapSource img = (BitmapSource)(image.Source); //rotate image and save CachedBitmap cache = new CachedBitmap(img, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); TransformedBitmap tb = new TransformedBitmap(cache, new RotateTransform(val)); TiffBitmapEncoder encoder = new TiffBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(tb)); using (FileStream file = File.OpenWrite(path)) { encoder.Save(file); } //update page view BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.UriSource = new Uri(path); bi.EndInit(); return bi; }

    Read the article

  • Need help using libpng to read an image

    - by jonathanasdf
    Here is my function... I don't know why it's not working. The resulting image looks nothing like what the .png looks like. But there's no errors either. bool Bullet::read_png(std::string file_name, int pos) { png_structp png_ptr; png_infop info_ptr; FILE *fp; if ((fp = fopen(file_name.c_str(), "rb")) == NULL) { return false; } png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { fclose(fp); return false; } info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { fclose(fp); png_destroy_read_struct(&png_ptr, NULL, NULL); return false; } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); return false; } png_init_io(png_ptr, fp); png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_SWAP_ALPHA | PNG_TRANSFORM_EXPAND, NULL); png_uint_32 width = png_get_image_width(png_ptr, info_ptr); png_uint_32 height = png_get_image_height(png_ptr, info_ptr); imageData[pos].width = width; imageData[pos].height = height; png_bytepp row_pointers; row_pointers = png_get_rows(png_ptr, info_ptr); imageData[pos].data = new unsigned int[width*height]; for (unsigned int i=0; i < height; ++i) { memcpy(&imageData[pos].data[i*width], &row_pointers[i], width*sizeof(unsigned int)); } png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); for (unsigned int i=0; i < height; ++i) { for (unsigned int j=0; j < width; ++j) { unsigned int val = imageData[pos].data[i*width+j]; if (val != 0) { unsigned int a = ((val >> 24)); unsigned int r = (((val - (a << 24)) >> 16)); unsigned int g = (((val - (a << 24) - (r << 16)) >> 8)); unsigned int b = (((val - (a << 24) - (r << 16) - (g << 8)))); // for debugging std::string s(AS3_StringValue(AS3_Int(i*width+j))); s += " "; s += AS3_StringValue(AS3_Int(val)); s += " "; s += AS3_StringValue(AS3_Int(a)); s += " "; s += AS3_StringValue(AS3_Int(r)); s += " "; s += AS3_StringValue(AS3_Int(g)); s += " "; s += AS3_StringValue(AS3_Int(b)); AS3_Trace(AS3_String(s.c_str())); } } } return true; } ImageData is just a simple struct to keep x, y, width, and height, and imageData is an array of that struct. struct ImageData { int x; int y; int width; int height; unsigned int* data; }; Here is a side by side screenshot of the input and output graphics (something I made in a minute for testing), and this was after setting alpha to 255 in order to make it show up (because the alpha I was getting back was 1). Left side is original, right side is what happened after reading it through this function. Scaled up 400% for visibility. Here is a log of the traces: 0 16855328 1 1 49 32 1 16855424 1 1 49 128 2 16855456 1 1 49 160 3 16855488 1 1 49 192 4 16855520 1 1 49 224 5 16855552 1 1 50 0 6 16855584 1 1 50 32 7 16855616 1 1 50 64 8 16855424 1 1 49 128 9 16855456 1 1 49 160 10 16855488 1 1 49 192 11 16855520 1 1 49 224 12 16855552 1 1 50 0 13 16855584 1 1 50 32 14 16855616 1 1 50 64 15 16855648 1 1 50 96 16 16855456 1 1 49 160 17 16855488 1 1 49 192 18 16855520 1 1 49 224 19 16855552 1 1 50 0 20 16855584 1 1 50 32 21 16855616 1 1 50 64 22 16855648 1 1 50 96 23 16855680 1 1 50 128 24 16855488 1 1 49 192 25 16855520 1 1 49 224 26 16855552 1 1 50 0 27 16855584 1 1 50 32 28 16855616 1 1 50 64 29 16855648 1 1 50 96 30 16855680 1 1 50 128 31 16855712 1 1 50 160 32 16855520 1 1 49 224 33 16855552 1 1 50 0 34 16855584 1 1 50 32 35 16855616 1 1 50 64 36 16855648 1 1 50 96 37 16855680 1 1 50 128 38 16855712 1 1 50 160 39 16855744 1 1 50 192 40 16855552 1 1 50 0 41 16855584 1 1 50 32 42 16855616 1 1 50 64 43 16855648 1 1 50 96 44 16855680 1 1 50 128 45 16855712 1 1 50 160 46 16855744 1 1 50 192 47 16855776 1 1 50 224 48 16855584 1 1 50 32 49 16855616 1 1 50 64 50 16855648 1 1 50 96 51 16855680 1 1 50 128 52 16855712 1 1 50 160 53 16855744 1 1 50 192 54 16855776 1 1 50 224 55 16855808 1 1 51 0 56 16855616 1 1 50 64 57 16855648 1 1 50 96 58 16855680 1 1 50 128 59 16855712 1 1 50 160 60 16855744 1 1 50 192 61 16855776 1 1 50 224 62 16855808 1 1 51 0 63 16855840 1 1 51 32 64 16855648 1 1 50 96 65 16855680 1 1 50 128 66 16855712 1 1 50 160 67 16855744 1 1 50 192 68 16855776 1 1 50 224 69 16855808 1 1 51 0 70 16855840 1 1 51 32 71 16855872 1 1 51 64 72 16855680 1 1 50 128 73 16855712 1 1 50 160 74 16855744 1 1 50 192 75 16855776 1 1 50 224 76 16855808 1 1 51 0 77 16855840 1 1 51 32 78 16855872 1 1 51 64 79 16855904 1 1 51 96 80 16855712 1 1 50 160 81 16855744 1 1 50 192 82 16855776 1 1 50 224 83 16855808 1 1 51 0 84 16855840 1 1 51 32 85 16855872 1 1 51 64 86 16855904 1 1 51 96 87 16855936 1 1 51 128 88 16855744 1 1 50 192 89 16855776 1 1 50 224 90 16855808 1 1 51 0 91 16855840 1 1 51 32 92 16855872 1 1 51 64 93 16855904 1 1 51 96 94 16855936 1 1 51 128 95 16855968 1 1 51 160 96 16855776 1 1 50 224 97 16855808 1 1 51 0 98 16855840 1 1 51 32 99 16855872 1 1 51 64 100 16855904 1 1 51 96 101 16855936 1 1 51 128 102 16855968 1 1 51 160 103 16856000 1 1 51 192 104 16855808 1 1 51 0 105 16855840 1 1 51 32 106 16855872 1 1 51 64 107 16855904 1 1 51 96 108 16855936 1 1 51 128 109 16855968 1 1 51 160 110 16856000 1 1 51 192 111 16856032 1 1 51 224 112 16855840 1 1 51 32 113 16855872 1 1 51 64 114 16855904 1 1 51 96 115 16855936 1 1 51 128 116 16855968 1 1 51 160 117 16856000 1 1 51 192 118 16856032 1 1 51 224 119 16856064 1 1 52 0 120 16855872 1 1 51 64 121 16855904 1 1 51 96 122 16855936 1 1 51 128 123 16855968 1 1 51 160 124 16856000 1 1 51 192 125 16856032 1 1 51 224 126 16856064 1 1 52 0 127 16856096 1 1 52 32 128 16855904 1 1 51 96 129 16855936 1 1 51 128 130 16855968 1 1 51 160 131 16856000 1 1 51 192 132 16856032 1 1 51 224 133 16856064 1 1 52 0 134 16856096 1 1 52 32 135 16856128 1 1 52 64 136 16855936 1 1 51 128 137 16855968 1 1 51 160 138 16856000 1 1 51 192 139 16856032 1 1 51 224 140 16856064 1 1 52 0 141 16856096 1 1 52 32 142 16856128 1 1 52 64 143 16856160 1 1 52 96 144 16855968 1 1 51 160 145 16856000 1 1 51 192 146 16856032 1 1 51 224 147 16856064 1 1 52 0 148 16856096 1 1 52 32 149 16856128 1 1 52 64 150 16856160 1 1 52 96 151 16856192 1 1 52 128 152 16856000 1 1 51 192 153 16856032 1 1 51 224 154 16856064 1 1 52 0 155 16856096 1 1 52 32 156 16856128 1 1 52 64 157 16856160 1 1 52 96 158 16856192 1 1 52 128 159 16856224 1 1 52 160 160 16856032 1 1 51 224 161 16856064 1 1 52 0 162 16856096 1 1 52 32 163 16856128 1 1 52 64 164 16856160 1 1 52 96 165 16856192 1 1 52 128 166 16856224 1 1 52 160 167 16856256 1 1 52 192 168 16856064 1 1 52 0 169 16856096 1 1 52 32 170 16856128 1 1 52 64 171 16856160 1 1 52 96 172 16856192 1 1 52 128 173 16856224 1 1 52 160 174 16856256 1 1 52 192 175 16856288 1 1 52 224 176 16856096 1 1 52 32 177 16856128 1 1 52 64 178 16856160 1 1 52 96 179 16856192 1 1 52 128 180 16856224 1 1 52 160 181 16856256 1 1 52 192 182 16856288 1 1 52 224 183 16856320 1 1 53 0 184 16856128 1 1 52 64 185 16856160 1 1 52 96 186 16856192 1 1 52 128 187 16856224 1 1 52 160 188 16856256 1 1 52 192 189 16856288 1 1 52 224 190 16856320 1 1 53 0 192 16856160 1 1 52 96 193 16856192 1 1 52 128 194 16856224 1 1 52 160 195 16856256 1 1 52 192 196 16856288 1 1 52 224 197 16856320 1 1 53 0 200 16856192 1 1 52 128 201 16856224 1 1 52 160 202 16856256 1 1 52 192 203 16856288 1 1 52 224 204 16856320 1 1 53 0 208 16856224 1 1 52 160 209 16856256 1 1 52 192 210 16856288 1 1 52 224 211 16856320 1 1 53 0 216 16856256 1 1 52 192 217 16856288 1 1 52 224 218 16856320 1 1 53 0 224 16856288 1 1 52 224 225 16856320 1 1 53 0 232 16856320 1 1 53 0 Was stuck on this for a couple of days.

    Read the article

  • libpng cannot read an image properly

    - by jonathanasdf
    Here is my function... I don't know why it's not working. The resulting image looks nothing like what the .png looks like. But there's no errors either. bool Bullet::read_png(std::string file_name, int pos) { png_structp png_ptr; png_infop info_ptr; FILE *fp; if ((fp = fopen(file_name.c_str(), "rb")) == NULL) { return false; } png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { fclose(fp); return false; } info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { fclose(fp); png_destroy_read_struct(&png_ptr, NULL, NULL); return false; } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); return false; } png_init_io(png_ptr, fp); png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_SWAP_ALPHA | PNG_TRANSFORM_EXPAND, NULL); png_uint_32 width = png_get_image_width(png_ptr, info_ptr); png_uint_32 height = png_get_image_height(png_ptr, info_ptr); imageData[pos].width = width; imageData[pos].height = height; png_bytepp row_pointers; row_pointers = png_get_rows(png_ptr, info_ptr); imageData[pos].data = new unsigned int[width*height]; for (unsigned int i=0; i < height; ++i) { memcpy(&imageData[pos].data[i*width], &row_pointers[i], width*sizeof(unsigned int)); } png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); for (unsigned int i=0; i < height; ++i) { for (unsigned int j=0; j < width; ++j) { unsigned int val = imageData[pos].data[i*width+j]; if (val != 0) { unsigned int a = ((val >> 24)); unsigned int r = (((val - (a << 24)) >> 16)); unsigned int g = (((val - (a << 24) - (r << 16)) >> 8)); unsigned int b = (((val - (a << 24) - (r << 16) - (g << 8)))); // for debugging std::string s(AS3_StringValue(AS3_Int(i*width+j))); s += " "; s += AS3_StringValue(AS3_Int(val)); s += " "; s += AS3_StringValue(AS3_Int(a)); s += " "; s += AS3_StringValue(AS3_Int(r)); s += " "; s += AS3_StringValue(AS3_Int(g)); s += " "; s += AS3_StringValue(AS3_Int(b)); AS3_Trace(AS3_String(s.c_str())); } } } return true; } ImageData is just a simple struct to keep x, y, width, and height, and imageData is an array of that struct. struct ImageData { int x; int y; int width; int height; unsigned int* data; }; Here is a side by side screenshot of the input and output graphics (something I made in a minute for testing), and this was after setting alpha to 255 in order to make it show up (because the alpha I was getting back was 1). Left side is original, right side is what happened after reading it through this function. Scaled up 400% for visibility. Here is a log of the traces: 0 16855328 1 1 49 32 1 16855424 1 1 49 128 2 16855456 1 1 49 160 3 16855488 1 1 49 192 4 16855520 1 1 49 224 5 16855552 1 1 50 0 6 16855584 1 1 50 32 7 16855616 1 1 50 64 8 16855424 1 1 49 128 9 16855456 1 1 49 160 10 16855488 1 1 49 192 11 16855520 1 1 49 224 12 16855552 1 1 50 0 13 16855584 1 1 50 32 14 16855616 1 1 50 64 15 16855648 1 1 50 96 16 16855456 1 1 49 160 17 16855488 1 1 49 192 18 16855520 1 1 49 224 19 16855552 1 1 50 0 20 16855584 1 1 50 32 21 16855616 1 1 50 64 22 16855648 1 1 50 96 23 16855680 1 1 50 128 24 16855488 1 1 49 192 25 16855520 1 1 49 224 26 16855552 1 1 50 0 27 16855584 1 1 50 32 28 16855616 1 1 50 64 29 16855648 1 1 50 96 30 16855680 1 1 50 128 31 16855712 1 1 50 160 32 16855520 1 1 49 224 33 16855552 1 1 50 0 34 16855584 1 1 50 32 35 16855616 1 1 50 64 36 16855648 1 1 50 96 37 16855680 1 1 50 128 38 16855712 1 1 50 160 39 16855744 1 1 50 192 40 16855552 1 1 50 0 41 16855584 1 1 50 32 42 16855616 1 1 50 64 43 16855648 1 1 50 96 44 16855680 1 1 50 128 45 16855712 1 1 50 160 46 16855744 1 1 50 192 47 16855776 1 1 50 224 48 16855584 1 1 50 32 49 16855616 1 1 50 64 50 16855648 1 1 50 96 51 16855680 1 1 50 128 52 16855712 1 1 50 160 53 16855744 1 1 50 192 54 16855776 1 1 50 224 55 16855808 1 1 51 0 56 16855616 1 1 50 64 57 16855648 1 1 50 96 58 16855680 1 1 50 128 59 16855712 1 1 50 160 60 16855744 1 1 50 192 61 16855776 1 1 50 224 62 16855808 1 1 51 0 63 16855840 1 1 51 32 64 16855648 1 1 50 96 65 16855680 1 1 50 128 66 16855712 1 1 50 160 67 16855744 1 1 50 192 68 16855776 1 1 50 224 69 16855808 1 1 51 0 70 16855840 1 1 51 32 71 16855872 1 1 51 64 72 16855680 1 1 50 128 73 16855712 1 1 50 160 74 16855744 1 1 50 192 75 16855776 1 1 50 224 76 16855808 1 1 51 0 77 16855840 1 1 51 32 78 16855872 1 1 51 64 79 16855904 1 1 51 96 80 16855712 1 1 50 160 81 16855744 1 1 50 192 82 16855776 1 1 50 224 83 16855808 1 1 51 0 84 16855840 1 1 51 32 85 16855872 1 1 51 64 86 16855904 1 1 51 96 87 16855936 1 1 51 128 88 16855744 1 1 50 192 89 16855776 1 1 50 224 90 16855808 1 1 51 0 91 16855840 1 1 51 32 92 16855872 1 1 51 64 93 16855904 1 1 51 96 94 16855936 1 1 51 128 95 16855968 1 1 51 160 96 16855776 1 1 50 224 97 16855808 1 1 51 0 98 16855840 1 1 51 32 99 16855872 1 1 51 64 100 16855904 1 1 51 96 101 16855936 1 1 51 128 102 16855968 1 1 51 160 103 16856000 1 1 51 192 104 16855808 1 1 51 0 105 16855840 1 1 51 32 106 16855872 1 1 51 64 107 16855904 1 1 51 96 108 16855936 1 1 51 128 109 16855968 1 1 51 160 110 16856000 1 1 51 192 111 16856032 1 1 51 224 112 16855840 1 1 51 32 113 16855872 1 1 51 64 114 16855904 1 1 51 96 115 16855936 1 1 51 128 116 16855968 1 1 51 160 117 16856000 1 1 51 192 118 16856032 1 1 51 224 119 16856064 1 1 52 0 120 16855872 1 1 51 64 121 16855904 1 1 51 96 122 16855936 1 1 51 128 123 16855968 1 1 51 160 124 16856000 1 1 51 192 125 16856032 1 1 51 224 126 16856064 1 1 52 0 127 16856096 1 1 52 32 128 16855904 1 1 51 96 129 16855936 1 1 51 128 130 16855968 1 1 51 160 131 16856000 1 1 51 192 132 16856032 1 1 51 224 133 16856064 1 1 52 0 134 16856096 1 1 52 32 135 16856128 1 1 52 64 136 16855936 1 1 51 128 137 16855968 1 1 51 160 138 16856000 1 1 51 192 139 16856032 1 1 51 224 140 16856064 1 1 52 0 141 16856096 1 1 52 32 142 16856128 1 1 52 64 143 16856160 1 1 52 96 144 16855968 1 1 51 160 145 16856000 1 1 51 192 146 16856032 1 1 51 224 147 16856064 1 1 52 0 148 16856096 1 1 52 32 149 16856128 1 1 52 64 150 16856160 1 1 52 96 151 16856192 1 1 52 128 152 16856000 1 1 51 192 153 16856032 1 1 51 224 154 16856064 1 1 52 0 155 16856096 1 1 52 32 156 16856128 1 1 52 64 157 16856160 1 1 52 96 158 16856192 1 1 52 128 159 16856224 1 1 52 160 160 16856032 1 1 51 224 161 16856064 1 1 52 0 162 16856096 1 1 52 32 163 16856128 1 1 52 64 164 16856160 1 1 52 96 165 16856192 1 1 52 128 166 16856224 1 1 52 160 167 16856256 1 1 52 192 168 16856064 1 1 52 0 169 16856096 1 1 52 32 170 16856128 1 1 52 64 171 16856160 1 1 52 96 172 16856192 1 1 52 128 173 16856224 1 1 52 160 174 16856256 1 1 52 192 175 16856288 1 1 52 224 176 16856096 1 1 52 32 177 16856128 1 1 52 64 178 16856160 1 1 52 96 179 16856192 1 1 52 128 180 16856224 1 1 52 160 181 16856256 1 1 52 192 182 16856288 1 1 52 224 183 16856320 1 1 53 0 184 16856128 1 1 52 64 185 16856160 1 1 52 96 186 16856192 1 1 52 128 187 16856224 1 1 52 160 188 16856256 1 1 52 192 189 16856288 1 1 52 224 190 16856320 1 1 53 0 192 16856160 1 1 52 96 193 16856192 1 1 52 128 194 16856224 1 1 52 160 195 16856256 1 1 52 192 196 16856288 1 1 52 224 197 16856320 1 1 53 0 200 16856192 1 1 52 128 201 16856224 1 1 52 160 202 16856256 1 1 52 192 203 16856288 1 1 52 224 204 16856320 1 1 53 0 208 16856224 1 1 52 160 209 16856256 1 1 52 192 210 16856288 1 1 52 224 211 16856320 1 1 53 0 216 16856256 1 1 52 192 217 16856288 1 1 52 224 218 16856320 1 1 53 0 224 16856288 1 1 52 224 225 16856320 1 1 53 0 232 16856320 1 1 53 0 Was stuck on this for a couple of days.

    Read the article

  • "image contains error", trying to create and display images using google app engine

    - by bert
    Hello all the general idea is to create a galaxy-like map. I run into problems when I try to display a generated image. I used Python Image library to create the image and store it in the datastore. when i try to load the image i get no error on the log console and no image on the browser. when i copy/paste the image link (including datastore key) i get a black screen and the following message: The image “view-source:/localhost:8080/img?img_id=ag5kZXZ-c3BhY2VzaW0xMnINCxIHTWFpbk1hcBgeDA” cannot be displayed because it contains errors. the firefox error console: Error: Image corrupt or truncated: /localhost:8080/img?img_id=ag5kZXZ-c3BhY2VzaW0xMnINCxIHTWFpbk1hcBgeDA import cgi import datetime import urllib import webapp2 import jinja2 import os import math import sys from google.appengine.ext import db from google.appengine.api import users from PIL import Image #SNIP #class to define the map entity class MainMap(db.Model): defaultmap = db.BlobProperty(default=None) #SNIP class Generator(webapp2.RequestHandler): def post(self): #SNIP test = Image.new("RGBA",(100, 100)) dMap=MainMap() dMap.defaultmap = db.Blob(str(test)) dMap.put() #SNIP result = db.GqlQuery("SELECT * FROM MainMap LIMIT 1").fetch(1) if result: print"item found<br>" #debug info if result[0].defaultmap: print"defaultmap found<br>" #debug info string = "<div><img src='/img?img_id=" + str(result[0].key()) + "' width='100' height='100'></img>" print string else: print"nothing found<br>" else: self.redirect('/?=error') self.redirect('/') class Image_load(webapp2.RequestHandler): def get(self): self.response.out.write("started Image load") defaultmap = db.get(self.request.get("img_id")) if defaultmap.defaultmap: try: self.response.headers['Content-Type'] = "image/png" self.response.out.write(defaultmap.defaultmap) self.response.out.write("Image found") except: print "Unexpected error:", sys.exc_info()[0] else: self.response.out.write("No image") #SNIP app = webapp2.WSGIApplication([('/', MainPage), ('/generator', Generator), ('/img', Image_load)], debug=True) the browser shows the "item found" and "defaultmap found" strings and a broken imagelink the exception handling does not catch any errors Thanks for your help Regards Bert

    Read the article

  • Image generated with PHP dosn't show

    - by lolalola
    Hi, whats wrong with my code. image dosn't show in test2.php file File: test2.php: <img src = "test.php" /> File: test.php session_start(); $md5_hash = md5(rand(0,999)); $security_code = substr($md5_hash, 15, 5); $_SESSION["security_code"] = $security_code; $width = 100; $height = 20; header("Content-type: image/png"); $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $grey = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $black); //Add randomly generated string in white to the image ImageString($image, 3, 30, 3, $security_code, $white); //Throw in some lines to make it a little bit harder for any bots to break imageRectangle($image,0,0,$width-1,$height-1,$grey); imageline($image, 0, $height/2, $width, $height/2, $grey); imageline($image, $width/2, 0, $width/2, $height, $grey); imagepng($image); imagedestroy($image);

    Read the article

  • Saving image from Gallery to db - Coursor IllegalStateException

    - by MyWay
    I want to save to db some strings with image. Image can be taken from gallery or user can set the sample one. In the other activity I have a listview which should present the rows with image and name. I'm facing so long this problem. It occurs when I wanna display listview with the image from gallery, If the sample image is saved in the row everything works ok. My problem is similar to this one: how to save image taken from camera and show it to listview - crashes with "IllegalStateException" but I can't find there the solution for me My table in db looks like this: public static final String KEY_ID = "_id"; public static final String ID_DETAILS = "INTEGER PRIMARY KEY AUTOINCREMENT"; public static final int ID_COLUMN = 0; public static final String KEY_NAME = "name"; public static final String NAME_DETAILS = "TEXT NOT NULL"; public static final int NAME_COLUMN = 1; public static final String KEY_DESCRIPTION = "description"; public static final String DESCRIPTION_DETAILS = "TEXT"; public static final int DESCRIPTION_COLUMN = 2; public static final String KEY_IMAGE ="image" ; public static final String IMAGE_DETAILS = "BLOP"; public static final int IMAGE_COLUMN = 3; //method which create our table private static final String CREATE_PRODUCTLIST_IN_DB = "CREATE TABLE " + DB_TABLE + "( " + KEY_ID + " " + ID_DETAILS + ", " + KEY_NAME + " " + NAME_DETAILS + ", " + KEY_DESCRIPTION + " " + DESCRIPTION_DETAILS + ", " + KEY_IMAGE +" " + IMAGE_DETAILS + ");"; inserting statement: public long insertToProductList(String name, String description, byte[] image) { ContentValues value = new ContentValues(); // get the id of column and value value.put(KEY_NAME, name); value.put(KEY_DESCRIPTION, description); value.put(KEY_IMAGE, image); // put into db return db.insert(DB_TABLE, null, value); } Button which add the picture and onActivityResult method which saves the image and put it into the imageview public void AddPicture(View v) { // creating specified intent which have to get data Intent intent = new Intent(Intent.ACTION_PICK); // From where we want choose our pictures intent.setType("image/*"); startActivityForResult(intent, PICK_IMAGE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); // if identification code match to the intent, //if yes we know that is our picture, if(requestCode ==PICK_IMAGE ) { // check if the data comes with intent if(data!= null) { Uri chosenImage = data.getData(); String[] filePathColumn = {MediaStore.Images.Media.DATA}; Cursor cursor = getContentResolver().query(chosenImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePat = cursor.getString(columnIndex); cursor.close(); ImageOfProduct = BitmapFactory.decodeFile(filePat); if(ImageOfProduct!=null) { picture.setImageBitmap(ImageOfProduct); } messageDisplayer("got picture, isn't null " + IdOfPicture); } } } Then the code which converts bitmap to byte[] public byte[] bitmapToByteConvert(Bitmap bit ) { // stream of data getted for compressed bitmap ByteArrayOutputStream gettedData = new ByteArrayOutputStream(); // compressing method bit.compress(CompressFormat.PNG, 0, gettedData); // our byte array return gettedData.toByteArray(); } The method which put data to the row: byte[] image=null; // if the name isn't put to the editView if(name.getText().toString().trim().length()== 0) { messageDisplayer("At least you need to type name of product if you want add it to the DB "); } else{ String desc = description.getText().toString(); if(description.getText().toString().trim().length()==0) { messageDisplayer("the description is set as none"); desc = "none"; } DB.open(); if(ImageOfProduct!= null){ image = bitmapToByteConvert(ImageOfProduct); messageDisplayer("image isn't null"); } else { BitmapDrawable drawable = (BitmapDrawable) picture.getDrawable(); image = bitmapToByteConvert(drawable.getBitmap()); } if(image.length>0 && image!=null) { messageDisplayer(Integer.toString(image.length)); } DB.insertToProductList(name.getText().toString(), desc, image ); DB.close(); messageDisplayer("well done you add the product"); finish(); You can see that I'm checking here the length of array to be sure that I don't send empty one. And here is the place where Error appears imo, this code is from activity which presents the listview with data taken from db private void LoadOurLayoutListWithInfo() { // firstly wee need to open connection with db db= new sqliteDB(getApplicationContext()); db.open(); // creating our custom adaprer, the specification of it will be typed // in our own class (MyArrayAdapter) which will be created below ArrayAdapter<ProductFromTable> customAdapter = new MyArrayAdapter(); //get the info from whole table tablecursor = db.getAllColumns(); if(tablecursor != null) { startManagingCursor(tablecursor); tablecursor.moveToFirst(); } // now we moving all info from tablecursor to ourlist if(tablecursor != null && tablecursor.moveToFirst()) { do{ // taking info from row in table int id = tablecursor.getInt(sqliteDB.ID_COLUMN); String name= tablecursor.getString(sqliteDB.NAME_COLUMN); String description= tablecursor.getString(sqliteDB.DESCRIPTION_COLUMN); byte[] image= tablecursor.getBlob(3); tablefromDB.add(new ProductFromTable(id,name,description,image)); // moving until we didn't find last row }while(tablecursor.moveToNext()); } listView = (ListView) findViewById(R.id.tagwriter_listoftags); //as description says // setAdapter = The ListAdapter which is responsible for maintaining //the data backing this list and for producing a view to represent //an item in that data set. listView.setAdapter(customAdapter); } I put the info from row tho objects which are stored in list. I read tones of question but I can't find any solution for me. Everything works when I put the sample image ( which is stored in app res folder ). Thx for any advice

    Read the article

  • Facebook Game Rejected: "Your app icon must not overlap with content in your cover image"

    - by peterwilli
    Sorry if this isnt the right stackexchange site to ask this, it was really hard to determine. My FB game just recently got rejected for 2 reasons. The first I fixed nicely and is irrelevant but the second I just can't see to figure out what they mean and I was hoping someone else got the same issue and did know what they meant. These are the errors: You can ignore the error under "Banners" The web preview of my game looks like this now: All I know is that the rejection has something to do with the cover image, not the icons or the screenshots. Please let me know what to do to get approved. Thanks a lot!

    Read the article

  • Absorbtion 2d image effect

    - by Ed.
    I want to create a specyfic 2d image effect. It consists in modifying a sprite so it looks like it is being zoomed to a point or "absorbed" by that point. I'm not really sure what is the technical name of this effect so I cannot explain it correctly. Here you can see a video of what I'm talking about, it is the effect when the character absorbs the three glyphs. http://www.youtube.com/watch?v=PIo-GddsMcU&t=4m45s What is the name of this effect? How can I implement it with XNA for 2D textures/sprites?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >