dimanche 1 mars 2015

UITableView Cell showing wrong image

I have a IUTableView with two Cells. One Cell with an image and one without an image. When the Cell without the image is shown below the Cell with the image everything is fine (Image 1). But when I sort the list and the Cell without the image is shown above the Cell with the image, the Cell without the image is showing the same image as the other Cell (Image 2). I am struggling with this problem for days now but I can't find out where the problem is.


Here is the Code for setting the image:



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

Object *myObject = [[Datamodel sharedInstance] objectAtIndex:(int)indexPath.row];
cell.textLabel.text = myObject.name;

if([myObject.imageNames count] != 0 && !myObject.thumbnail)
{
knife.knifeThumbnail = [[NSString alloc] initWithString:[knife.knifeImageNames objectAtIndex:0]];
}

if(myObject.thumbnail)
{
NSLog(@"Setting thumbnail");
NSString *pathToImgData= [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents" ]stringByAppendingPathComponent:@"ImgData"];
NSMutableString *imgPath = [[NSMutableString alloc] initWithString:pathToImgData];
[imgPath appendString:@"/"];
[imgPath appendString: myObject.thumbnail];
UIImage* image = [UIImage imageWithContentsOfFile:imgPath];
UIImageView *imv = [[UIImageView alloc]initWithFrame:CGRectMake(8, 8, 128, cellHeight-16)];
imv.image = image;
[cell addSubview:imv];
}
return cell;


}


Regarding the console output only one object enters the "if(myObject.thumbnail)" condition so only for the Cell that should have an image, the image ist set:



2015-03-01 ***** Cell with image *****
2015-03-01 --> Setting the image

2015-03-01 ***** Cell wihout image *****
2015-03-01 --> NOT setting the image

2015-03-01 ***** Cell without image *****
2015-03-01 --> NOT setting the image
2015-03-01 ***** Cell with image *****
2015-03-01 --> Setting the image


And the Code for sorting the list:



-(void)sortList{

NSSortDescriptor *sortObjectName = [NSSortDescriptor sortDescriptorWithKey:@"objectName" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) {
return [obj1 caseInsensitiveCompare:obj2];
}];
[self.arrayData sortUsingDescriptors:@[sortObjectName]];


}


It's probably more like a theoretical question but still.


It is pretty simple to use inline base64 data to pass it in image source parameter. We are doing it like that: <img src="data:image/png;base64,[base64 string]" />.


But what if the data that represented in this base64 string is gzipped? Is there a way to tell the browser about it? It can be simply done when the image is loaded from a HTTP server by adding Content-Encoding: gzip header. But is it possible with the inline method?


I couldn't find any information about this. The only solution that I see is use JavaScript to "unbase64" the data, "gunzip" it and then "base64" it again and put it to the src attribute.


But it not seem to be a good solution...


ExifInterface returns 0

I'm trying to get the image orientation using ExifInterface class but i always get 0.


Snippet:



ExifInterface ei;

try {
ei = new ExifInterface("/storage/sdcard0/etp_images/31_demo2@gmail.com.jpg");
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

Log.v("ORIENTATION", String.valueOf(orientation));

} catch (IOException e) {
e.printStackTrace();
}


I was looking many answers about this question but none has result me. Thanks in advance.


div backgroundImage withd input result

I'm using this tech : link to get images from local clients, i don't want save it on my server. Can i (in javascript) set a div backgroundImage width this image ? Now this is my code :



var input9I1 = document.createElement("input");
input9I1.id = "input9I1";
input9I1.type = "file";
input9I1.name = "files[]";
input9I1.accept = "image/*";
input9I1.addEventListener('change', handleFileSelect, false);
td20I1.appendChild(input9I1);


So it was the creation of the input and it work fine. Now the function :



function handleFileSelect(evt){
imgageATraiter = evt.target.files[0];

console.log(imgageATraiter.name);
console.log(imgageATraiter.type);
console.log(imgageATraiter.size);
console.log(imgageATraiter.lastModifiedDate);
console.log(imgageATraiter.lastModifiedDate.toLocaleDateString());

document.getElementById('boite5I1').style.backgroundImage = imgageATraiter.name;}


So what i want is how can i modify the "boite5I1" 's background with my image ? Is it possible ? Thanks to read and have a good day :D


How to count Color on Image using HTML canvas getImageData()?

How to using getImageData() to count color on image? I want to get and show number of count.


HTML Image Changing Position

I have images on my website (for now, I'm using height and width giving a number in pixels) but what I have noticed is that when I stretch my browser, my images tend to get totally messed up.


So I need a little help making them static so if a user stretches their browser, the pictures will stay in their position without getting moved around.


If anyone can help me with this, it will be highly appreciated! Thanks!


how to save a BinaryString into a Image Object

Im developing a CSHTML web page where i ask my clients to upload an image onto the page. I receive the image from the html form, and stored inside the @c code as binary string.


Inside the C script how can i transfer this string of bits into an displayable image. which object should i use?