简体   繁体   中英

Is a cursor greater than 512x512 pixels in size possible?

Goal:
I'm trying to create a cursor file which can cover the whole screen with a flashlight effect on a full hd (1920x1080) screen. For that, the cursor image resolution would need to be at 4K (3840x2160) along with having an alpha channel (32bpp). Axialis Cursor Workshop is the only cursor creation program I've tried which goes above the usual 256² pixel limit, but still caps at 512² pixels...

File format analysis:
Looking at the file format specifications, the usual upper bound of 256² pixels might be caused by the CUR/ICO format working with 8 bits for width and height fields each. ANI format looks more promising since it has 32 bits reserved for those. On the flip side, it seems to have no hotspot fields, and itself uses CUR/ICO format for the animation frames, unless the IconFlag bit is set to FALSE . Looking at a cursor file produced by Axialis CW, I see the flag set to TRUE weirdly enough.

Hex edit approach:
I've tried inserting raster data from a (converted) bmp of same size (521²) by the means of hex editing. Then I tried to insert raster data from a 1024² bpm, updating image dimensions and the file size in the headers. Which only kind of works, I guess.

I'd appreciate any help or pointers in the right direction.


Related things, in no particular order:

Got it working with Hex Editor Neo and a binary template I put together for the ico/cur file format:

// ico.h
#pragma once
#pragma byte_order(LittleEndian)
#include "stddefs.h"
#include "bitmap.h"
 
struct ICONDIRENTRY;
struct ICONFILE;
 
public struct ICONDIR {
    [description("")]
    uint16 Reserved;
    $assert(Reserved==0);
    
    [description("Specifies image type: 1 for icon (.ICO) image, 2 for cursor (.CUR) image. Other values are invalid.")]
    uint16 Type;
    
    [description("Specifies number of images in the file.")]
    uint16 Count;
    
    [description("")]
    ICONDIRENTRY Entries[Count];
};
 
struct ICONDIRENTRY {
    var entryIndex = array_index;
    
    [description("Cursor Width")]
    uint8 Width;
    
    [description("Cursor Height (added height of XORbitmap and ANDbitmap). A negative value would indicate pixel order being top to bottom")]
    int8 Height;
    
    [description("Specifies number of colors in the color palette. Should be 0 if the image does not use a color palette.")]
    uint8 ColorCount;
    
    [description("")]
    uint8 Reserved;
    $assert(Reserved==0);
    
    [description("In ICO format: Specifies color planes. Should be 0 or 1. In CUR format: Specifies the horizontal coordinates of the hotspot in number of pixels from the left.")]
    uint16 XHotspot;
    
    [description("In ICO format: Specifies bits per pixel. In CUR format: Specifies the vertical coordinates of the hotspot in number of pixels from the top.")]
    uint16 YHotspot;
    
    [description("Size of (InfoHeader + ANDBitmap + XORBitmap)")]
    uint32 SizeInBytes;
    [description("FilePos, where InfoHeader starts")]
    uint32 FileOffset as ICONFILE*;
};
 
struct ICONFILE {
    BITMAPINFO Info;
    
    // no idea why this isn't working
    /*var bmiv1header = BITMAPINFOHEADER(Info.bmiHeader);
    var size = bmiv1header.biSizeImage;
    if(size == 0) {
        size = Entries[entryIndex].SizeInBytes - bmiv1header.biSize;
    }
    uint8 RawData[size];*/
    uint8 __firstPixel;
};

The cursor file I created successfully looks something like this with the template applied:

https://i.imgur.com/1zD4qx6.png

The trick was to set value of the image height field in the BITMAPHEADERINFO structure to twice the amount of pixels in height. The reason for this is that two separate pixel arrays are expected which are applied using bitwise XOR and AND. I was surprised when it already worked in the preview without even adding an AND pixel array. Seems like you can omit that or something, idk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM