PROCCESING-Pixel operations are not supported on this device - save

Any code I write that requires save(), saveFrame() or functions like loadpixels() I can't use, what's stopping me from saving edited pitcures.
Error it says its: Pixel operations are not supported on this device.
About my computer:
Windows7 ultimate Service pack 1, 64-bit
AMD A10-5800K APU with Radeon(tm) HD Graphics 3.80 GHZ
UPDATE
It works on any other computer just not mine, even some basic codes like this one for example
size(640,480);
background(255);
fill(44);
beginShape();
vertex(50,20);
vertex(600,160);
vertex(190,400);
endShape(CLOSE);
saveFrame("izlaz1.jpg");

I suppose that your Windows' color depth setting is set too low.
Processing assumes that system exposes color depth as 32-bit (RGB + alpha = 4*8bit).
This is fragment from PGraphicsJava2D class:
protected WritableRaster getRaster() {
...
if (raster.getTransferType() != DataBuffer.TYPE_INT) {
System.err.println("See https://github.com/processing/processing/issues/2010");
throw new RuntimeException("Pixel operations are not supported on this device.");
}
return raster;
}
So "Pixel operations are not supported" exception is raised when your system exposes to low color depth.
Try to change your Windows' setting.
Some helper links below:
https://github.com/processing/processing/issues/2010
http://helpx.adobe.com/x-productkb/global/change-color-depth-resolution-windows.html

Related

Is there a way to determine the Physical Sector Size for removable drives with file systems other than NTFS (like FAT16, exFAT...)?

I need a function to get the Physical Sector Size for all kind of system drives, in Win7 or higher.
This is the code that I've used until today, when I found out that it's not working with my external USB HDD (exFAT file system) and with my USB MP3 Player (FAT16). In these cases the function DeviceIoControl fails and I get the exception: "System Error. Code 50. The request is not suported". But it works very well with NTFS volumes.
function GetSectorSize(Drive:Char):DWORD;
var h:THandle;
junk:DWORD;
Query:STORAGE_PROPERTY_QUERY;
Alignment:STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR;
begin
result:=0;
h:=CreateFileW(PWideChar('\\.\'+UpperCase(Drive)+':'),0,FILE_SHARE_READ or FILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);
if h=INVALID_HANDLE_VALUE then RaiseLastOSError;
try
FillChar(Query,SizeOf(Query),0);
Query.PropertyId:=StorageAccessAlignmentProperty;
Query.QueryType:=PropertyStandardQuery;
if not DeviceIoControl(h,IOCTL_STORAGE_QUERY_PROPERTY,#Query,SizeOf(Query),#Alignment,SizeOf(Alignment),junk,nil) then RaiseLastOSError;
result:=Alignment.BytesPerPhysicalSector;
finally
CloseHandle(h);
end;
end;
According to MSDN:
File Buffering
Most current Windows APIs, such as IOCTL_DISK_GET_DRIVE_GEOMETRY and GetDiskFreeSpace, will return the logical sector size, but the physical sector size can be retrieved through the IOCTL_STORAGE_QUERY_PROPERTY control code, with the relevant information contained in the BytesPerPhysicalSector member in the STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR structure. For an example, see the sample code at STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR. Microsoft strongly recommends that developers align unbuffered I/O to the physical sector size as reported by the IOCTL_STORAGE_QUERY_PROPERTY control code to help ensure their applications are prepared for this sector size transition.
This same quote also appears in the following MSDN document:
Advanced format (4K) disk compatibility update
Which includes the following additional information:
The below list summarizes the new features delivered as part of Windows 8 and Windows Server 2012 to help improve customer and developer experience with large sector disks. More detailed description for each item follow.
...
•Provides a new API to query for physical sector size (FileFsSectorSizeInformation)
...
Here’s how you can query for the physical sector size:
Preferred method for Windows 8
With Windows 8, Microsoft has introduced a new API that enables developers to easily integrate 4K support within their apps. This new API supports even greater numbers of scenarios than the legacy method for Windows Vista and Windows 7 discussed below. This API enables these calling scenarios:
•Calling from an unprivileged app
•Calling to any valid file handle
•Calling to a file handle on a remote volume over SMB2
•Simplified programming model
The API is in the form of a new info class, FileFsSectorSizeInformation, with associated structure FILE_FS_SECTOR_SIZE_INFORMATION
FILE_FS_SECTOR_SIZE_INFORMATION structure
This information can be queried in either of the following ways:
•Call FltQueryVolumeInformation or ZwQueryVolumeInformationFile, passing FileFsSectorSizeInformation as the value of FileInformationClass and passing a caller-allocated, FILE_FS_SECTOR_SIZE_INFORMATION-structured buffer as the value of FileInformation.
•Create an IRP with major function code IRP_MJ_QUERY_VOLUME_INFORMATION.
•Call FsRtlGetSectorSizeInformation with a pointer to a FILE_FS_SECTOR_SIZE_INFORMATION-structured buffer. The FileSystemEffectivePhysicalBytesPerSectorForAtomicity member will not have a value initialized by the file system when this structure is returned from FsRtlGetSectorSizeInformation. A file system driver will typically call this function and then set its own value for FileSystemEffectivePhysicalBytesPerSectorForAtomicity.
Your principal error is that you try to get physical sector size from a volume handle rather than from that of an underlying physical device (\\.\PhysicalDriveX). Device's physical sector size doesn't depend on FS and shouldn't be confused with a logical sector size defined by FS properties.

First Chance Exception

I am following a tutorial to learn game programming with DirectX11. When I run the sample code it gives me this error:
First-chance exception at 0x76E12EEC in Chapter1.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x0307E824. HRESULT:0x887A0004
The problem appears to be in featureLevel and creationFlag in the following code:
hr = D3D11CreateDevice(
nullptr,
D3D_DRIVER_TYPE_HARDWARE,
nullptr,
creationFlags,
featureLevels,
ARRAYSIZE(featureLevels),
D3D11_SDK_VERSION,
&device,
&featureLevel,
&context);
ThrowIfFailed(hr);
However, if I change values of creationFlags and featureLevels to 0 and nullptr, the code works fine. I am using Visual Studio 2012 with Windows 8.1 and Windows SDK 8.0.
Here is the relevant code:
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#if defined(_DEBUG)
// For debugging
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
};
I read about first chance exception that it doesn't mean there is something really wrong with code, but it doesn't just go away. What should I do?
Issue
You passing only D3D_FEATURE_LEVEL_11_1 and D3D_FEATURE_LEVEL_11_0, so D3D11CreateDevice() function fails, returns HRESULT which is not S_OK and your ThrowIfFailed(hr); function throws exception you've got.
You cannot create DirectX 11 hardware device and context if your GPU only supports DirectX 10: Createdevice*() function will fail. To be able to use DirectX 11 API (but not DirectX 11 features) on down-level hardware Microsoft introduced feature levels.
How to fix?
Just use conventional way of device creation.
You will need to pass array with all possible feature levels
D3D_FEATURE_LEVEL arrFeatLevels [] =
{
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1,
};
so, DirectX API will automatically choose the highest supported one.
(After device creation, you can find which one was chosen by looking at returned &featureLevel):
if(featureLevel >= D3D_FEATURE_LEVEL_11_0)
std::cout << "Yay! we using D3D11! :) " << std::endl;
else if( featureLevel >= D3D_FEATURE_LEVEL_10_0)
std::cout << "Oh noes! only D3D10 available! :(" <<std::endl;
else
std::cout << "Man, where did you take that old videocard? =\ " <<std::endl;
Note, that DirectX 11 features (such as Shader Model 5, tessellation shaders; compute shader) will not be available on device/context created with feature level lower than D3D_FEATURE_LEVEL_11_0. Same way, DirectX 10 features (e.g. geometry shader) will not be available with feature level lower than D3D_FEATURE_LEVEL_10_0.
All hardware supported features will run as usual.
Also, there are way to test features, that not supported by your hardware. You can create software emulated WARP device: pass D3D_DRIVER_TYPE_WARP. It is very slow and not intended for production code, but it permits developers test and debug D3D11 features even if they don't have top hardware.
Where to find my GPU's capabilities?
On GPU manufacturer's site. Or simply use tools like GPU-Z (it shows DX support) or GPU Caps Viewer (shows many OpenGL features).
Happy coding!= )

Check for WebGL support in Dart

I'm playing with WebGL and Dart and I can't figure out how to check if some object has certain method. For example in JavaScript I would check if WebGL is available with window.WebGLRenderingContext but is there a way to the same in Dart?
IIRC one of the goals of Dart was to normalize the inconsistencies of which browser defines what. As such, WebGL will always be "available" in that the interfaces for it will always exist in Dart wether or not the browser you are running on has them defined natively.
Wether or not WebGL is supported is probably best checked the same way you do in Javascript:
WebGLRenderingContext gl = canvas.getContext("experimental-webgl");
If gl is null then WebGL is not supported. Otherwise it is!
(BTW: just because window.WebGLRenderingContext exists in Javascript does NOT mean that WebGL is supported! That only tells you that the browser is capable of dispatching WebGL commands. The system that you are running on may not accept them. It's still best to try creating a context and detect when it fails.)
EDIT: By the way, there is a Dart way of initializing WebGL context:
RenderingContext gl = canvas.getContext3d();
if (gl == null) {
print("WebGL: initialization failure");
}
OLD ANSWER:
WebGLRenderingContext gl = canvas.getContext("experimental-webgl");
if (gl == null) {
print("WebGL is not supported");
return;
}
This code prints "WebGL is not supported" on Chrome JavaScript Console, when I turn on "Disable WebGL" under chrome://flags/.
However, with WebGL disabled under Firefox (about:config -> webgl.disabled;true), it yields error on Web Console:
NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLCanvasElement.getContext]
EDIT: This is the fixed bug for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=645792

how to use VxWorks etherOutputHookAdd

I'm stumped trying to get etherOutputHookAdd() to work. Its counterpart, etherInputHookAdd(), seems to work fine. The OS version in question is VxWorks 5.4 .
The hook code looks like so (the code I intend to actually run is more complicated, but this serves for an example.)
int anCounter;
STATUS etherHook(struct ifnet *pif, char *buf, int size)
{
anCounter += 1;
return FALSE;
}
I can hook up etherInputHookAdd from the vxworks shell like so
etherInputHookAdd etherHook,"fei",0
This returns 0 (STATUS OK), after which examination of the 'anCounter' variable will indicate activity as expected. However, no such luck with the output direction. I've tried both of these command lines
etherOutputHookAdd etherHook,"fei",0
etherOutputHookAdd etherHook
Both of these return OK, but the hook routine doesn't seem to be getting called at all. My best hypotheses are (1) I'm missing an initialization step, or calling it wrong, (2) the etherOutputHookAdd implementation is just a stub, (3) you just can't call it from the shell, or (4) maybe my nic driver implementation is buggy.
Any ideas that solve the central problem - how do I see what's being sent off my board - are welcome.
The following VxWorks network drivers support both the input-hook and output-hook routines:
if_cpm - Motorola MC68EN360 QUICC network interface driver
if_eex - Intel EtherExpress 16
if_ei - Intel 82596 ethernet driver
if_elc - SMC 8013WC Ethernet driver
if_elt - 3Com 3C509 Ethernet driver
if_ene - Novell/Eagle NE2000 network driver
if_fn - Fujitsu MB86960 NICE Ethernet driver
if_ln - Advanced Micro Devices Am7990 LANCE Ethernet driver
if_sm - shared memory backplane network interface driver
if_sn - National Semiconductor DP83932B SONIC Ethernet driver
if_ultra - SMC Elite Ultra Ethernet network interface driver
if_gn - generic MUX interface layer
The following drivers support only the input-hook routines:
if_nic - National Semiconductor SNIC Chip (for HKV30)
if_sl - Serial Line IP (SLIP) network interface driver
The following drivers support only the output-hook routines:
if_ulip - network interface driver for User Level IP (VxSim)
The following drivers do not support either the input-hook or output-hook routines:
if_loop - software loopback network interface driver
To those few who might stumble this way .. It was the horrible 'hypothesis 4'!
It turns out that in order for etherOutputHookAdd() to work correctly, it is incumbent on the NIC device driver writer to include a call to the function pointed to by etherOutputHookRtn. All etherOutputHookAdd() does is add your proffered packet handler to a list, so that when a NIC driver calls etherOutputHookRtn, you get a copy of what's being transmitted. Sadly, there are many drivers where for whatever reason, this was simply not done.
So in cases such as this one, there are only two courses of action.
find a patch for your driver, or patch it yourself
change tactics entirely, e.g., try using etherInputHookAdd() on the other side.
In case you migrate to a newer version (>6.x) of VxWorks , etherLib is no longer supported. Instead, one can use muxLib for a similar purpose.
Hook inbound traffic: Use muxBind with MUX_PROTO_PROMISC or MUX_PROTO_OUTPUT.
Hook outbound traffic: Use muxBind with MUX_PROTO_OUTPUT.
You should provide a callback routine in both cases.

Reading and writing DEVMODE.dmColor

I'm having trouble with the dmColor field fo the DEVMODE structure.
My default printer is a color printer, if I default output color of the printer properties through the control panel to black and white the DEVMODE.dmColor field always returns DMCOLOR_COLOR instead of DMCOLOR_MONOCHROME.
Even if I default my printer to a black and white only printer, DEVMODE.dmColor still always returns DMCOLOR_COLOR
All of the other DEVMODE fields such as dmDeviceName, dmCopies, dmDuplex, etc work fine. I have also tried to query DC_COLORDEVICE using the DeviceCapabilities function, microsoft documentation says it should return 1 if the device supports color, 0 if it does not and -1 if an error occured. This function is always returning -1 but the error code returned by GetLastError translates to "The operation completed successfully".
I'm running under windows Vista and I have specified DM_COLOR in DEVMODE.dmFields, does anyone know why this happens?
I've solved the issue, it seems like the color setting along with other settings are stored in the private drive data section below the DEVMODE structure. The size of the private data is stored in DEVMODE.dmDriverExtra. Copying the private driver data returned from the printer properties dialog box to the printing device has fixed the problem.
This might be a driver issue.
I'm having the exactly opposite on my HP 2840 color multifunctional: the XP specific drivers work well (allowing both color and monochrome), but they are not supported on Vista and higher.
From Vista on, you need to use the Generic HP drivers, which always return monochrome.
--jeroen

Resources