- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每次进入 View 时,使用的内存都会增加..即使我正在保存图像。有时应用程序会因内存不足警告而崩溃。有人可以告诉我解决方案,这样图像内存就不会增加。
#import <UIKit/UIKit.h>
#import "PatientStudiesViewController.h"
#import "CareServices.h"
@interface newImageComparison : UIViewController<UIScrollViewDelegate,ServerConnectionDelegate>
{
NSString *serverUrlStr;
NSString *studyID;
NSString *instID;
NSString *urlEncodedKey;
NSMutableArray *myCompareImage1;
NSMutableArray *myCompareImage2;
UIScrollView * _scrollView1;
UIScrollView * _scrollView2;
NSMutableArray *selectedStudyIDArr;
NSMutableDictionary *SelectedImageTypeDict;
NSMutableArray *selectedImagetypeTagsArr;
BOOL isRightEyeSelectedAgain;
BOOL isLeftEyeSelectedAgain;
NSMutableArray *demoCompareODArr;
NSMutableArray *demoCompareOSArr;
CareServices *careServices;
}
-(void)prepareODImages_selectedStudyIDString1 :(NSString *)selectedIDString1;
-(void)prepareOSImages_selectedStudyIDString2 :(NSString *)selectedIDString2;
- (void)loadImageRightEyeImage:(NSMutableArray *)urlAndTagReference;
- (void)loadImageLeftEyeImage:(NSMutableArray *)urlAndTagReference;
@end
#import "newImageComparison.h"
#import "XMLParserForStudyDetails.h"
#import "ColorSchemes.h"
#import <CommonCrypto/CommonDigest.h>
#import "mach/mach.h"
@implementation newImageComparison
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
careServices = [CareServices currentInstance];
careServices.delegate = self;
NSUserDefaults *selectedStudy = [NSUserDefaults standardUserDefaults];
selectedStudyIDArr = [selectedStudy valueForKey:@"selectedStudyIDArray"];
NSUserDefaults *selectedImagetype = [NSUserDefaults standardUserDefaults];
SelectedImageTypeDict = [selectedImagetype valueForKey:@"imageTypeDict"];
NSUserDefaults *selectedImageTypeTags = [NSUserDefaults standardUserDefaults];
selectedImagetypeTagsArr = [selectedImageTypeTags valueForKey:@"selectedImageTypeTags"];
NSMutableArray *imageType = [[NSMutableArray alloc]init];
for (int count = 0; count <[selectedImagetypeTagsArr count]; count++) {
[imageType addObject:[SelectedImageTypeDict valueForKey:[selectedImagetypeTagsArr objectAtIndex:count]]];
}
self.view.backgroundColor = [UIColor blackColor];
[super viewDidLoad];
myCompareImage1 = [[NSMutableArray alloc]init];
myCompareImage2 = [[NSMutableArray alloc]init];
NSUserDefaults *realUrl = [NSUserDefaults standardUserDefaults];
serverUrlStr = [realUrl valueForKey:@"serverUrl"];
NSString *key;
NSUserDefaults *keyD = [NSUserDefaults standardUserDefaults];
key = [keyD valueForKey:@"key"];
urlEncodedKey = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)key, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingASCII);
NSUserDefaults *studyID_D = [NSUserDefaults standardUserDefaults];
studyID = [studyID_D valueForKey:@"studyID"];
NSUserDefaults *instID_D = [NSUserDefaults standardUserDefaults];
instID = [instID_D valueForKey:@"instID"];
NSMutableArray *selectedDateArray = [[NSUserDefaults standardUserDefaults]valueForKey:@"selectedDateArray"];
demoCompareODArr = [[NSMutableArray alloc]init];
demoCompareOSArr = [[NSMutableArray alloc]init];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(60, 2, 200, 20)];
label.backgroundColor = [UIColor clearColor];
label.text = [NSString stringWithFormat:@"%@/%@/%@",[selectedStudyIDArr objectAtIndex:0],[selectedDateArray objectAtIndex:0],[imageType objectAtIndex:0]];
label.font = [UIFont systemFontOfSize:15];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor greenColor];
[self.view addSubview:label];
[label release];
label = [[UILabel alloc]initWithFrame:CGRectMake(60, 208, 200, 20)];
label.text = [NSString stringWithFormat:@"%@/%@/%@",[selectedStudyIDArr objectAtIndex:1],[selectedDateArray objectAtIndex:1],[imageType objectAtIndex:1]];
label.font = [UIFont systemFontOfSize:15];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor greenColor];
label.textAlignment = UITextAlignmentCenter;
[self.view addSubview:label];
[label release];
NSMutableDictionary *selectedDemoImagesDict = [[NSUserDefaults standardUserDefaults]valueForKey:@"selectedDemoImagesDict"];
if ([[imageType objectAtIndex:0] isEqualToString:@"OD"]) {
[self prepareODImages_selectedStudyIDString1:[selectedStudyIDArr objectAtIndex:0]];
}
else {
isLeftEyeSelectedAgain = YES;
[self prepareOSImages_selectedStudyIDString2:[selectedStudyIDArr objectAtIndex:0]];
}
if ([[imageType objectAtIndex:1]isEqualToString:@"OS"]) {
[self prepareOSImages_selectedStudyIDString2:[selectedStudyIDArr objectAtIndex:1]];
}
else {
isRightEyeSelectedAgain = YES;
[self prepareODImages_selectedStudyIDString1:[selectedStudyIDArr objectAtIndex:1]];
}
self.navigationItem.title = @"Image Comparsion";
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidAppear:(BOOL)animated {
UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(27,23,265,184)];
imageView1.image = [UIImage imageNamed:@"plainbg_3.png"];
[self.view addSubview:imageView1];
UIImageView *imageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(27,228,265,184)];
imageView2.image = [UIImage imageNamed:@"plainbg_3.png"];
[self.view addSubview:imageView2];
_scrollView1 = [[UIScrollView alloc]initWithFrame:CGRectMake(33,30,252,172)];
_scrollView1.delegate = self;
_scrollView1.backgroundColor = [UIColor clearColor];
_scrollView1.pagingEnabled = YES;
_scrollView1.scrollEnabled = YES;
[self.view addSubview:_scrollView1];
_scrollView2 = [[UIScrollView alloc]initWithFrame:CGRectMake(33,234,252,172)];
_scrollView2.delegate = self;
_scrollView2.backgroundColor = [UIColor clearColor];
_scrollView2.pagingEnabled = YES;
_scrollView2.scrollEnabled = YES;
[self.view addSubview:_scrollView2];
int x_val = -252;
int y_val = 0;
float dis = 0;
for (int seriesCount = 0; seriesCount <[myCompareImage1 count]; seriesCount++) {
NSMutableArray *OD = [[NSMutableArray alloc]init];
OD = [myCompareImage1 objectAtIndex:seriesCount];
for (int count = 0; count <[OD count]; count++) {
dis = dis+252;
UIImageView *R_EyeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x_val+dis, y_val, 252, 172)];
R_EyeImageView.backgroundColor = [UIColor blackColor];
R_EyeImageView.tag = seriesCount *100+100+count;
[_scrollView1 addSubview:R_EyeImageView];
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activity setFrame:CGRectMake(R_EyeImageView.frame.size.width/2.3,R_EyeImageView.frame.size.height/2.2, 40, 40)];
activity.tag = seriesCount*100+100+count;
[R_EyeImageView addSubview:activity];
[activity startAnimating];
[activity release];
[R_EyeImageView release];
}
[self loadImageRightEyeImage:OD];
[OD release];
}
_scrollView1.contentSize = CGSizeMake(dis, 0);
dis = 0;
for (int seriesCount = 0; seriesCount <[myCompareImage2 count]; seriesCount++) {
NSMutableArray *OS = [[NSMutableArray alloc]init];
OS = [myCompareImage2 objectAtIndex:seriesCount];
for (int count = 0; count <[OS count]; count++) {
dis = dis+252;
UIImageView *L_EyeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x_val+dis, y_val, 252, 172)];
L_EyeImageView.backgroundColor = [UIColor blackColor];
L_EyeImageView.tag = seriesCount *100+100+count;
[_scrollView2 addSubview:L_EyeImageView];
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activity setFrame:CGRectMake(L_EyeImageView.frame.size.width/2.3,L_EyeImageView.frame.size.height/2.2, 40, 40)];
activity.tag = seriesCount*100+100+count;
[L_EyeImageView addSubview:activity];
[activity startAnimating];
[activity release];
[L_EyeImageView release];
}
[self loadImageLeftEyeImage:OS];
[OS release];
}
_scrollView2.contentSize = CGSizeMake(dis, 0);
[_scrollView1 release];
[_scrollView2 release];
[imageView1 release];
[imageView2 release];
}
- (void)prepareODImages_selectedStudyIDString1:(NSString *)selectedIDString1 {
NSMutableArray *arr = [[XMLParserForStudyDetails sharedManager].final_ImagesDict valueForKey:selectedIDString1];
NSMutableArray *imageIDArr = [[XMLParserForStudyDetails sharedManager].imageID_RefDict_3D valueForKey:selectedIDString1];
NSMutableArray *seriesID = [[XMLParserForStudyDetails sharedManager].SeriesRefID_Dict valueForKey:selectedIDString1];
for (int count = 0; count <[seriesID count]; count++) {
NSMutableDictionary *imageDict = [arr objectAtIndex:0];
NSMutableArray *imageIDArr2 = [imageIDArr objectAtIndex:count];
NSString *seriesID1 = [seriesID objectAtIndex:count];
NSMutableArray *arr = [[NSMutableArray alloc]init];
NSMutableDictionary *imageDict2 = [imageDict valueForKey:seriesID1];
for (int count2 = 0; count2 <[imageIDArr2 count]; count2++) {
NSString *str;
NSMutableDictionary *imageDict3 = [imageDict2 valueForKey:[imageIDArr2 objectAtIndex:count2]];
if ([[imageDict3 valueForKey:@"imageType"] isEqualToString:@"image"]) {
if ([[imageDict3 valueForKey:@"num_frames"]isEqualToString:@"1"]) {
if ([[imageDict3 valueForKey:@"laterality"] isEqualToString:@"R"]) {
str = [[NSString alloc]initWithFormat:@"http://%@/i2icareclientws/i2iCareAPI_Service.asmx/GetImage?key=%@&study_id=%@&series_id=%@&image_id=%@&image_level=3&format=&frame_number=&imageType=1",serverUrlStr,urlEncodedKey,selectedIDString1,seriesID1,[imageIDArr2 objectAtIndex:count2]];
[arr addObject:str];
[str release];
}
}
}
}
if (isRightEyeSelectedAgain == YES) {
[myCompareImage2 addObject:arr];
isRightEyeSelectedAgain = NO;
}
else {
[myCompareImage1 addObject:arr];
}
[arr release];
}
}
- (void)prepareOSImages_selectedStudyIDString2:(NSString *)selectedIDString2 {
NSMutableArray *arr = [[XMLParserForStudyDetails sharedManager].final_ImagesDict valueForKey:selectedIDString2];
NSMutableArray *imageIDArr = [[XMLParserForStudyDetails sharedManager].imageID_RefDict_3D valueForKey:selectedIDString2];
NSMutableArray *seriesID = [[XMLParserForStudyDetails sharedManager].SeriesRefID_Dict valueForKey:selectedIDString2];
for (int count = 0; count <[seriesID count]; count++) {
NSMutableDictionary *imageDict = [arr objectAtIndex:0];
NSMutableArray *imageIDArr2 = [imageIDArr objectAtIndex:count];
NSString *seriesID1 = [seriesID objectAtIndex:count];
NSMutableArray *arr = [[NSMutableArray alloc]init];
NSMutableDictionary *imageDict2 = [imageDict valueForKey:seriesID1];
for (int count2 = 0; count2 <[imageIDArr2 count]; count2++) {
NSString *str;
NSMutableDictionary *imageDict3 = [imageDict2 valueForKey:[imageIDArr2 objectAtIndex:count2]];
if ([[imageDict3 valueForKey:@"imageType"] isEqualToString:@"image"]) {
if ([[imageDict3 valueForKey:@"num_frames"]isEqualToString:@"1"]) {
if ([[imageDict3 valueForKey:@"laterality"] isEqualToString:@"L"]) {
str = [[NSString alloc]initWithFormat:@"http://%@/i2icareclientws/i2iCareAPI_Service.asmx/GetImage?key=%@&study_id=%@&series_id=%@&image_id=%@&image_level=3&format=&frame_number=&imageType=1",serverUrlStr,urlEncodedKey,selectedIDString2,seriesID1,[imageIDArr2 objectAtIndex:count2]];
[arr addObject:str];
[str release];
}
}
}
}
if (isLeftEyeSelectedAgain == YES) {
[myCompareImage1 addObject:arr];
isLeftEyeSelectedAgain = NO;
}
else {
[myCompareImage2 addObject:arr];
}
[arr release];
}
}
- (void)loadImageRightEyeImage:(NSMutableArray *)urlAndTagReference {
for (int count = 0; count <[myCompareImage1 count]; count ++) {
for (int i = 0; i < [urlAndTagReference count]; i++) {
NSString *imagePath = [urlAndTagReference objectAtIndex:i];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"amp;" withString:@""];
imagePath = [imagePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *key = [self sha1:imagePath];
NSString *fileToSave = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg",key]];
for ( UIImageView *imgView in _scrollView1.subviews) {
if (imgView.tag == count *100+100+i) {
for (UIActivityIndicatorView *activity in [imgView subviews]) {
if ([activity isKindOfClass:[UIActivityIndicatorView class]]) {
if (activity.tag == count *100+100+i) {
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:fileToSave];
if (!fileExists)
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul);
dispatch_async(queue, ^{
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]];
UIImage *image = [[UIImage alloc] initWithData:imageData];
NSData *jpegData = UIImageJPEGRepresentation(image,0.001);
[[NSFileManager defaultManager] createFileAtPath:fileToSave contents:jpegData attributes:nil];
dispatch_sync(dispatch_get_main_queue(), ^{
imgView.image = image;
[activity stopAnimating];
[activity removeFromSuperview];
});
});
}else{
UIImage *image = [UIImage imageWithContentsOfFile:fileToSave];
if(!image) image = [UIImage imageNamed:@"rest-blank-thumbnail.png"];
imgView.image = image;
[activity removeFromSuperview];
}
}
}
}
}
}
}
}
}
- (void)loadImageLeftEyeImage:(NSMutableArray *)urlAndTagReference {
for (int count = 0; count <[myCompareImage2 count]; count ++) {
for (int i = 0; i < [urlAndTagReference count]; i++) {
NSString *imagePath = [urlAndTagReference objectAtIndex:i];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"amp;" withString:@""];
imagePath = [imagePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *key = [self sha1:imagePath];
NSString *fileToSave = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg",key]];
for ( UIImageView *imgView in _scrollView2.subviews) {
if (imgView.tag == count *100+100+i) {
for (UIActivityIndicatorView *activity in [imgView subviews]) {
if ([activity isKindOfClass:[UIActivityIndicatorView class]]) {
if (activity.tag == count *100+100+i) {
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:fileToSave];
if (!fileExists)
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul);
dispatch_async(queue, ^{
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]];
UIImage *image = [[UIImage alloc] initWithData:imageData];
NSData *jpegData = UIImageJPEGRepresentation(image,0.001);
[[NSFileManager defaultManager] createFileAtPath:fileToSave contents:jpegData attributes:nil];
dispatch_sync(dispatch_get_main_queue(), ^{
imgView.image = image;
[activity stopAnimating];
[activity removeFromSuperview];
});
});
}else{
UIImage *image = [UIImage imageWithContentsOfFile:fileToSave];
if(!image) image = [UIImage imageNamed:@"rest-blank-thumbnail.png"];
imgView.image = image;
[activity removeFromSuperview];
}
}
}
}
}
}
}
}
}
-(NSString*) sha1: (NSString *)str
{
const char *cstr = [str cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:str.length];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, data.length, digest);
NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
[output appendFormat:@"%02x", digest[i]];
return output;
}
- (void)viewDidUnload {
_scrollView1 = nil;
_scrollView2 = nil;
}
- (void)dealloc {
[myCompareImage1 release];
[myCompareImage2 release];
}
最佳答案
如果您打开了“僵尸”(方案诊断),那么实际上不会删除任何内容。因此,在 RAM 较少的设备(如 iPad 1)上,您将很快耗尽内存并收到内存警告。模拟器一般不会有这个问题。
关于即使我正在释放,iPhone 应用程序也会由于收到内存警告而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13156789/
我有一个加号/减号按钮,希望用户不能选择超过 20 个但不知道如何让它工作。我尝试使用 min="1"max="5 属性,但它们不起作用。这是我的代码和一个 fiddle 链接。https://jsf
我正在尝试复制顶部底部图,如示例 here但它没有正确渲染(紫色系列有 +ve 和 -ve 值,绿色为负值)留下杂乱的人工制品。我也在努力创建一个玩具示例来复制这个问题,所以我希望尽管我缺乏数据,但有
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭 6 年前。 社区去年审查了是
这个问题在这里已经有了答案: Adding two positive integers gives negative answer.Why? (4 个答案) 关闭 5 年前。 我遇到了一个奇怪的问题
有谁知道如何将字符串值类型 -4,5 或 5,4 转换为 double -4.5 或 5.4? 最佳答案 只需使用 Double.parseDouble(Locale, String); 糟糕,我很困
我正在尝试根据 TextBlob 分类插入一个仅包含“正”或“负”字符串的新数据框列:对于我的 df 的第一行,结果是 ( pos , 0.75, 0.2499999999999997)我想要' 正
我对 VBA 非常陌生,无法理解如何在一个循环中完成 2 个任务。我非常感谢您的帮助。 我已经能够根据第 3 列中的数据更改第 2 列中的数值,但我不明白如何将负值的字体更改为红色。 表格的大小每月都
欢迎, 我正在使用 jquery 通过 POST 发送表单。 这就是我获得值(value)的方式。 var mytext = $("#textareaid").val(); var dataStrin
double d = 0; // random decimal value with it's integral part within the range of Int32 and always p
我有这个字符串: var a='abc123#xyz123'; 我想构建 2 个正则表达式替换函数: 1) 用 '*' 替换所有确实有 future '#'的字符(不包括'#') 所以结果应该是这样的
我正在使用 DialogFragment。当用户从 Gmail 平板电脑应用程序的屏幕与下面示例图片中的编辑文本进行交互时,我希望正面和负面按钮保持在键盘上方。 在我的尝试中不起作用,这是我的 Dia
从组装艺术一书中,我复制了这句话: In the two’s complement system, the H.O. bit of a number is a sign bit. If the H.O
是否有更好更优雅的方法来实现下面的简单代码(diffYear、A 和 B 是数字): diffYear = yearA - yearB; if (diffYear == 0) { A = B
我正在设计一种语言,并尝试确定 true 应该是 0x01 还是 0xFF。显然,所有非零值都将转换为 true,但我正在尝试确定确切的内部表示。 每种选择的优点和缺点是什么? 最佳答案 没关系,只要
在我的 dialogfragment 类的 OnCreateDialog 中,我正在这样做: AlertDialog.Builder builder = new AlertDialog.Builder
这个问题在这里已经有了答案: Resolving ambiguous overload on function pointer and std::function for a lambda usin
我偶然发现了一个奇怪的 NSDecimalNumber 行为:对于某些值,调用 integerValue、longValue、longLongValue 等,返回意想不到的值(value)。示例: l
这个问题在这里已经有了答案: Resolving ambiguous overload on function pointer and std::function for a lambda using
我有这个正则表达式来测试用户输入是否有效: value.length === 0 || value === '-' || (!isNaN(parseFloat(value)) && /^-?\d+\.
我想用高斯混合模型拟合数据集,数据集包含大约 120k 个样本,每个样本有大约 130 个维度。当我使用 matlab 执行此操作时,我运行脚本(簇号为 1000): gm = fitgmdist(d
我是一名优秀的程序员,十分优秀!