7f8195344a
Define thumbnail attributes in Attributes.h: Media:Thumbnail to store the thumbnail, Media:Thumbnail:CreationTime to see if thumbs need to be regenerated. Store 128x128 thumbnail in attribute, for icon sizes smaller than 128x128 down-scale the 128x128 thumbnail. Use B_FILTER_BITMAP_BILINEAR to down-scale the image using the bilinear scaling algorithm which creates nicer looking thumbnails than the default scaling algorithm. Store thumbnails as WebP images which compress smaller than PNGs and fit in the inode better at 128x128. Check the file's modification time in GetFileIconFromAttr() and compare it to the thumbnail creation time. If the file has not been modified since the last time we generated thumbnails return the thumbnail from the attribute, otherwise fetch a new thumbnail with GetThumbnailIcon(). Add "Generate image thumbnails" Tracker setting. Default is turned off for now. To generate image thumbnails you must first turn this setting on in Tracker Windows preferences. Spawn a get_thumbnail() thread to generate thumbnails and retrieve them later on from the window thread to fill out into the icon. This should improve responsiveness of generating thumbnails from a folder with a lot of images. The generator thread will write the thumbnail data to an attribute if on writable BFS volume. If not on writable BFS volume, the generator thread will send the data back to the original thread through a port by calling write_port(). When the thread is finished creating the thumbnail it sends a message back to the Tracker application thread to update the pose which instructs the window thread to look for an thumbnail. It either finds a thumbnail in an attribute, or picks up the thumbnail data that has been sent through write_port() using read_port(). This works on both read-write and read-only BFS volumes but it still depends on the presence of a BEOS:TYPE parameter to have been written to the volume before it became read-only. Thumbnail generation does not work on other read-only volumes for example an ISO-9660 CD, but it does work on read-only BFS volumes for example the BeOS R5 CD. Move BPrivate::CheckNodeIconHintPrivate() from BNodeInfo to Tracker Model CheckNodeIconHint(). Create Model::CheckAppIconHint() and look for a vector icon or mini and large icon in that method. Check that the base type is directory, volume, trash, desktop, or if executable call CheckAppIconHint(). Add 1 to temp_name to fix the following warning: src/kits/tracker/FSUtils.cpp:2437:12: note: 'snprintf' output 3 or more bytes (assuming 267) into a destination of size 266 Rename temp_name to tempName following our style guidelines. Use strlcpy() and strlcat() instead of strcpy() to safely copy the string. This fixes thumbnail generation on 64-bit Haiku. Change-Id: I7f927a5a1f8cf65e4b1aa1e0eb55bbfae87fd969 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3163 Reviewed-by: John Scipione <jscipione@gmail.com> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
133 lines
2.6 KiB
C
133 lines
2.6 KiB
C
/*
|
|
* Copyright 2009, Haiku Inc. All Rights Reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _TRANSLATOR_FORMATS_H
|
|
#define _TRANSLATOR_FORMATS_H
|
|
|
|
|
|
#include <GraphicsDefs.h>
|
|
#include <Rect.h>
|
|
|
|
|
|
// Standard fields for the extension message
|
|
extern char B_TRANSLATOR_EXT_HEADER_ONLY[];
|
|
extern char B_TRANSLATOR_EXT_DATA_ONLY[];
|
|
extern char B_TRANSLATOR_EXT_COMMENT[];
|
|
extern char B_TRANSLATOR_EXT_TIME[];
|
|
extern char B_TRANSLATOR_EXT_FRAME[];
|
|
extern char B_TRANSLATOR_EXT_BITMAP_RECT[];
|
|
extern char B_TRANSLATOR_EXT_BITMAP_COLOR_SPACE[];
|
|
extern char B_TRANSLATOR_EXT_BITMAP_PALETTE[];
|
|
extern char B_TRANSLATOR_EXT_SOUND_CHANNEL[];
|
|
extern char B_TRANSLATOR_EXT_SOUND_MONO[];
|
|
extern char B_TRANSLATOR_EXT_SOUND_MARKER[];
|
|
extern char B_TRANSLATOR_EXT_SOUND_LOOP[];
|
|
|
|
|
|
// Standard formats
|
|
|
|
enum TranslatorGroups {
|
|
B_TRANSLATOR_BITMAP = 'bits',
|
|
B_TRANSLATOR_PICTURE = 'pict',
|
|
B_TRANSLATOR_SOUND = 'nois',
|
|
B_TRANSLATOR_TEXT = 'TEXT',
|
|
B_TRANSLATOR_MIDI = 'midi',
|
|
B_TRANSLATOR_MEDIA = 'mhi!',
|
|
B_TRANSLATOR_NONE = 'none',
|
|
B_TRANSLATOR_ANY_TYPE = 0
|
|
};
|
|
|
|
|
|
enum {
|
|
// Bitmap formats
|
|
B_GIF_FORMAT = 'GIF ',
|
|
B_JPEG_FORMAT = 'JPEG',
|
|
B_PNG_FORMAT = 'PNG ',
|
|
B_PPM_FORMAT = 'PPM ',
|
|
B_TGA_FORMAT = 'TGA ',
|
|
B_BMP_FORMAT = 'BMP ',
|
|
B_TIFF_FORMAT = 'TIFF',
|
|
B_WEBP_FORMAT = 'WebP',
|
|
|
|
// Picture formats
|
|
B_DXF_FORMAT = 'DXF ',
|
|
B_EPS_FORMAT = 'EPS ',
|
|
B_PICT_FORMAT = 'PICT',
|
|
|
|
// Sound formats
|
|
B_WAV_FORMAT = 'WAV ',
|
|
B_AIFF_FORMAT = 'AIFF',
|
|
B_CD_FORMAT = 'CD ',
|
|
B_AU_FORMAT = 'AU ',
|
|
|
|
// Text formats
|
|
B_STYLED_TEXT_FORMAT = 'STXT'
|
|
};
|
|
|
|
|
|
// Bitmap format (always in big endian)
|
|
struct TranslatorBitmap {
|
|
uint32 magic; // B_TRANSLATOR_BITMAP
|
|
BRect bounds;
|
|
uint32 rowBytes;
|
|
color_space colors;
|
|
uint32 dataSize;
|
|
|
|
// actual data follows
|
|
};
|
|
|
|
|
|
// Sound format (always in big endian)
|
|
struct TranslatorSound {
|
|
uint32 magic; // B_TRANSLATOR_SOUND
|
|
uint32 channels;
|
|
float sampleFreq;
|
|
uint32 numFrames;
|
|
|
|
// actual data follows
|
|
};
|
|
|
|
|
|
// Text format (always in big endian)
|
|
struct TranslatorStyledTextRecordHeader {
|
|
uint32 magic;
|
|
uint32 header_size;
|
|
uint32 data_size;
|
|
};
|
|
|
|
struct TranslatorStyledTextStreamHeader {
|
|
enum {
|
|
STREAM_HEADER_MAGIC = 'STXT'
|
|
};
|
|
|
|
TranslatorStyledTextRecordHeader header;
|
|
int32 version;
|
|
};
|
|
|
|
struct TranslatorStyledTextTextHeader {
|
|
enum {
|
|
TEXT_HEADER_MAGIC = 'TEXT'
|
|
};
|
|
|
|
TranslatorStyledTextRecordHeader header;
|
|
int32 charset;
|
|
|
|
// actual data follows
|
|
};
|
|
|
|
struct TranslatorStyledTextStyleHeader {
|
|
enum {
|
|
STYLE_HEADER_MAGIC = 'STYL'
|
|
};
|
|
|
|
TranslatorStyledTextRecordHeader header;
|
|
uint32 apply_offset;
|
|
uint32 apply_length;
|
|
|
|
// flattened style follows
|
|
};
|
|
|
|
|
|
#endif // _TRANSLATOR_FORMATS_H
|