자체 동적 아이콘을 갖기 위해 내 파일 형식으로 파일을 가져 오는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/120865

  •  02-07-2019
  •  | 
  •  

문제

우리의 응용 프로그램에는 opendocument 파일 형식과 유사한 파일 형식이 있습니다 ( http://en.wikipedia.org/wiki/opendocument) - 즉, 매니페스트 파일, 썸네일 이미지 등이 Zited.

OpenOffice 파일에는 Open Office 파일의 미리보기 이미지가 Windows와 Linux에서 아이콘으로 표시됩니다. 파일에 대해 이것을 달성 할 수있는 방법이 있습니까? 즉, 내부 썸네일을 기반으로 동적 아이콘을 원하십니까?

편집 1 와우, 모든 빠른 답변에 감사드립니다. 썸네일러 그놈 세계에 잘 어울립니다. Windows 나는 그 링크를 조사 할 것입니다. 감사합니다. 주석 질문에 관해서는 : 프로그래밍 방식으로 또는 설치 프로그램을 통해.

편집 2 오, 맥을 잊어 버렸어. Mac은 어떻습니까? (미안한 Mac 애호가!) 또한 OpenOffice가 아이콘 핸들러를 어떻게 수행하는지에 대한 링크 나 정보가 있습니까? 우리는 매우 비슷하기 때문입니까?

도움이 되었습니까?

해결책

당신이 필요로하는 것은 아이콘 핸들러, 썸네일 핸들러라고도합니다. 다음은 다음에 작성된 예입니다 활성 X 제어.

또 다른 리소스는 찾는 것입니다 속성 처리기, 또한 Windows에서 동적 메타 데이터를 올바르게 처리하는 최신의 가장 큰 방법을 지적해야합니다.

이것들은 동적 솔루션 - 모든 파일과 관련된 아이콘을 원한다면 필요하지 않습니다. Windows 탐색기가 확장자뿐만 아니라 파일의 내용과 파일이 변경 될 때 아이콘을 표시 할 때만 사용됩니다. 변경 사항을 반영하도록 아이콘이 업데이트됩니다. 파일 자체의 이미지 일 필요는 없으며, 썸네일 핸들러는 파일 내용을 기반으로 모든 이미지를 생성 할 수 있습니다.

속성 처리기는 노래 또는 비디오 길이와 같은 다른 메타 데이터를 업데이트하므로 모든 메타 데이터 Windows 탐색기 지원을 사용할 수 있습니다.

Mac 지원과 관련하여 이 페이지 "Mac 및 Windows 운영 체제는 이러한 유형의 썸네일을 활성화하는 다른 방법을 가지고 있으며, Mac OS의 경우,이 지원은 버전에서 버전으로 일치하지 않으므로 [Adobe Indesign]을 위해 추구되지 않았습니다. "

OS x

Mac OSX의 아이콘은 시작 서비스 데이터베이스. 그러나 등록 된 응용 프로그램에 의해 처리되는 모든 파일의 정적 아이콘 파일을 나타냅니다 (확장자를 기반으로하지 않습니다. 각 파일은 메타 데이터가하지 않을 때 확장자가 힌트를 제공하더라도 해당되는 애플리케이션을 결정하는 메타 데이터가 첨부되어 있습니다. 다른 OS 또는 파일 시스템에서 파일 가져 오기와 같은 존재)

OSX의 동적 아이콘 기능은 Finder가 제공하는 것으로 보이지만 검색은이 방향으로 쉬운 포인터를 불러 일으키지 않습니다. Finder가 시간이 지남에 따라 계속 변하기 때문에이 목표가 왜 어려운지 알 수 있습니다 ...

금언

그놈의 경우 a를 사용합니다 썸네일러. (감사해요 도워드)

이것은 당신이 쓰는 매우 간단한 프로그램으로, 3 가지 명령 줄 인수가 있습니다.

  • 입력 파일 이름, 썸네일로 설명하는 파일 (또는 대신 허용하는 경우 URI)
  • PNG를 작성 해야하는 출력 파일 이름
  • 생산 해야하는 최대 제곱 이미지 크기를 설명하는 크기, 숫자 (128-> 128x128 이하)

모든 시스템이 간단하기를 바랍니다. 반면에 이것은 애니메이션과 다른 시스템에서 플러그인을 구현하기가 더 어려운 몇 가지 다른 기능을 지원하지 않습니다.

kde

나는 조금 확실하지 않지만, 당신을 시작해야 할 몇 가지 포인터가 있습니다. 첫 번째는 Konqueror가 파일 관리자이며 아이콘을 표시한다는 것입니다. 일부 내장형 유형의 동적 아이콘을 지원하지만이 문제가 하드 코딩되어 있는지 또는 쓸 수 있는지 모르겠습니다. 확인하십시오 임베디드 구성 요소 자습서 출발점.

아이콘 및 아이콘 기능과 관련이있는 플라즈마 (Plasma)라는 새로운 (ISH?) 기능 (또는 계획된 기능 ...)이 있습니다. 체크 아웃 이 발표 그리고 이 초기 구현.

Konqueror의 소스를 파고 텍스트 파일과 이미 구현 된 다른 사람들에 대해 어떻게 수행했는지 확인해야 할 수도 있습니다.

-아담

다른 팁

버전 10.5 이후의 Mac OSX…

… 두 가지 접근 방식이 있습니다.

  1. 귀하의 문서는 표준 OSX 번들 형식이며 정적 이미지가 있습니다.이것은 하위 폴더 QuickLook을 만들고 썸네일/preview.png/tiff/jpg를 내부에 배치하여 수행 할 수 있습니다.

  2. 다른 모든 것 /library/QuickLook ~/library/QuickLook 또는 yourApp.App/contents/Library/QuickLook 폴더 안에 저장할 수있는 QuickLook Generator 플러그인이 필요합니다.

이 생성기는 썸네일과 QuickLook 미리보기를 즉시 생성하는 데 사용됩니다. Xcode는 이것을위한 템플릿을 제공합니다. 템플릿은 필요한 것을 생성합니다 ansi c 구현 해야하는 파일. 글을 쓰고 싶다면 대상 c 코드 GenerateThumbnailForurl의 이름을 바꿔야합니다. 그리고 생성 previewforurl. 생성 결장. 그리고 생성 previewforurl. (그리고 Apple Devel Docs를주의 깊게 읽으십시오;)))))))))


간단한 지퍼 컨테이너 기반 데모 :

Cocoa.framework and Foundation.framework를 GenerateThumbnailForurl.c에서 프로젝트에 추가해야합니다 (이것은 부분적으로 내 머리에서 나와 있으므로 상자 밖으로 작동한다는 것을 보장하지 않음) :) :

#include <Cocoa/Cocoa.h>
#include <Foundation/Foundation.h>

OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize)
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

  /* unzip the thumbnail and put it into an NSData object */
  // Create temporary path and writing handle for extraction
  NSString *tmpPath = [NSTemporaryDirectory() stringByAppendingFormat: [NSString stringWithFormat: @"%.0f.%@" , [NSDate timeIntervalSinceReferenceDate] * 1000.0, @"png"]];
  [[NSFileManager defaultManager] createFileAtPath: tmpPath contents: [NSData alloc] attributes:nil];
  NSFileHandle *writingHandle = [NSFileHandle fileHandleForWritingAtPath: tmpPath];


  // Use task to unzip - create command: /usr/bin/unzip -p <pathToFile> <fileToExtract>
  NSTask *unzipTask = [[NSTask alloc] init];
  [unzipTask setLaunchPath: @"/usr/bin/unzip"];

  // -p -> output to StandardOut, added File to extract, nil to terminate Array
  [unzipTask setArguments: [NSArray arrayWithObjects: @"-p", [(NSURL *) url path], @"Thumbnails/thumbnail.png", nil]];

  // redirect standardOut to writingHandle
  [unzipTask setStandardOutput: writingHandle];

  // Unzip - run task
  [unzipTask launch];
  [unzipTask waitUntilExit];

  // Read Image Data and remove File
  NSData *thumbnailData = [NSData dataWithContentsOfFile: tmpPath];
  [[NSFileManager defaultManager] removeFileAtPath: tmpPath handler:nil];


  if ( thumbnailData == nil || [thumbnailData length] == 0 ) {
     // Nothing Found. Don't care.
     [pool release];
     return noErr;
  }

  // That is the Size our image should have - create a dictionary too
  CGSize size = CGSizeMake(256, 256);
  NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
      [NSNumber numberWithInt:size.width],kQLPreviewPropertyWidthKey,
      [NSNumber numberWithInt:size.height],kQLPreviewPropertyHeightKey,
      nil];

  // Get CGContext for Thumbnail
  CGContextRef CGContext = QLThumbnailRequestCreateContext(thumbnail, size, TRUE, (CFDictionaryRef)properties);
  if(CGContext) {
     NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)CGContext flipped:size.width > size.height];
     if(context) {
        //These two lines of code are just good safe programming…
       [NSGraphicsContext saveGraphicsState];
       [NSGraphicsContext setCurrentContext:context];

       NSBitmapImageRep *thumbnailBitmap = [NSBitmapImageRep imageRepWithData:thumbnailData];
       [thumbnailBitmap draw];

       //This line sets the context back to what it was when we're done
       [NSGraphicsContext restoreGraphicsState];
    }

    // When we are done with our drawing code QLThumbnailRequestFlushContext() is called to flush the context
    QLThumbnailRequestFlushContext(thumbnail, CGContext);

    // Release the CGContext
    CFRelease(CGContext);
  }

  [pool release];
  return noErr;
}

info.plist

info.plist 파일도 수정해야합니다 - 열면 많은 필드가 사전 설정되어 있습니다. 그들 대부분은 자체 탐색 (또는 변경 될 필요가 없음)이지만 다음 구조를 추가해야했습니다 (복사 페이스트는 텍스트를 복사하고 Plist 편집기로 이동하여 붙여 넣기입니다.) : :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
   <dict>
     <key>UTTypeConformsTo</key>
     <array>
       <string>com.pkware.zip-archive</string>
     </array>
     <key>UTTypeDescription</key>
     <string>i-net Crystal-Clear Report File</string>
     <key>UTTypeIconName</key>
     <string>generic</string>
     <key>UTTypeIdentifier</key>
     <string>com.company.product</string>
     <key>UTTypeReferenceURL</key>
     <string>http://your-url.com</string>
     <key>UTTypeTagSpecification</key>
     <dict>
       <key>public.filename-extension</key>
         <array>
           <string>$fileEXT$</string>
         </array>
     </dict>
  </dict>
</array>
</plist>

Filetype $ FileExt $를 등록하고 시스템에 FilEtype이 Zipy 형식 유형임을 알려줍니다. 내가 여기서 사용한 좋은 반동은 GoogleCode의 QuickLook IPA 플러그인

Windows에서 필요한 것은 아이콘 핸들러를 구현하는 것입니다. 나는이 여러 달 전에이 일을했는데 COM의 기본 사항을 아는 한 어렵지 않습니다.

보다: http://msdn.microsoft.com/en-us/library/bb776857(vs.85).aspx

For Gnome you use a thumbnailer.

This is up to the operating system as far as I know, it will be based on the file extension.

Executables have the icon inside the file (potentially multiple) as a "resource".

Data files pick up an icon based on file association.

If you want a custom icon per file that is much harder. you either need too fool the OS into thinking it is an executable and embed the icon as a resource in the file, or deep link into the OS to override the default icon selection routine.

I think, "custom own" icon can have only PE files in windows. Every other icons for file extensions are stored in windows registry.

For specification of PE file, you can look at An In-Depth Look into the Win32 Portable Executable File Format and Peering Inside the PE: A Tour of the Win32 Portable Executable File Format.

How it works in other OS, I don't know :/.

I don't know about Linux, but for Windows you can start here: http://msdn.microsoft.com/en-us/library/bb774614.aspx

Edit: I think this interface is for the thumbnails shown in thumbnail view, not icons. Sorry for wasting your time.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top