问题描述
class Sample {
List analysis;
}
分析包含一个值
class Analysis {
Integer value;
}
该样本包含N个样本,但并非所有样本都具有值。在Querydsl中,我想按具有任何值的分析百分比对结果进行排序。
我已经尝试过了,但是看起来好像不是在计算值的数量。
query.orderBy(
new OrderSpecifier(
pRequest.getorder(),Expressions.asNumber(qSample.analysis.any().value.isNotNull().count().divide(qSample.analysis.size()) )
)
);
解决方法
尝试:
public class ImageEventArgs : EventArgs
{
public Bitmap bmap { get; set; }
}
public Bitmap GetSet(object bmp)
{
Bitmap bmap = (Bitmap)bmp;
Color theColor = new Color();
for (int i = 0; i < bmap.Width; i++)
{
for (int j = 0; j < bmap.Height; j++)
{
// Get the color of the pixel at (i,j)
theColor = bmap.GetPixel(i,j);
// Change the color at that pixel; DivideByZeroException out the green and blue
Color newColor = Color.FromArgb(theColor.R,theColor.G,0);
// Set the new color of the pixel
bmap.SetPixel(i,j,newColor);
}
}
OnImageFinished(bmap);
return bmap;
}
public Bitmap LockBits(object bmp)
{
Bitmap bmap = (Bitmap)bmp;
// Use "unsafe" becausae c# doesnt support pointer arithmetic by default
unsafe
{
// Lock the bitmap into system memory
// "Pixelformat" can be "Fomat24bppRgb","Format32bppArgb",etc.
BitmapData bitmapData =
bmap.LockBits(new Rectangle(0,bmap.Width,bmap.Height),ImageLockMode.ReadWrite,bmap.PixelFormat);
//Define variables for bytes per pixel,as well as Image Width & Height
int bytesPerPixel = System.Drawing.Bitmap.GetPixelFormatSize(bmap.PixelFormat) / 8;
int heightInPixels = bitmapData.Height;
int widthInBytes = bitmapData.Width * bytesPerPixel;
//Define a pointer to the first pixel in the locked image
// Scan0 gets or sets the address of the first pixel data in the bitmap
// This can also be thought of as the first scan line in the bitmap.
byte* PtrFirstPixel = (byte*)bitmapData.Scan0;
// Step through each pixel in the image using pointers
// Parallel.For executes a 'for' loop in which iterations
// may run in parralel
Parallel.For(0,heightInPixels,y =>
{
// USe the 'Stride' (scanline width) proerty to step line by line thru the image
byte* currentLine = PtrFirstPixel + (y * bitmapData.Stride);
for (int x = 0; x < widthInBytes; x = x + bytesPerPixel)
{
// GET: each pixel color (R,G,& B)
int oldBlue = currentLine[x];
int oldGreen = currentLine[x + 1];
int oldRed = currentLine[x + 2];
// SET: Zero out the Blue,copy Green and Red unchanged
currentLine[x] = 0;
currentLine[x + 1] = (byte)oldGreen;
currentLine[x + 2] = (byte)oldRed;
}
});
bmap.UnlockBits(bitmapData);
}
OnImageFinished(bmap);
return bmap;
}