小编Oue*_*ine的帖子

将PNG加载到TImage

我试图使用PNGImage库将PNG图像加载到TImage,

每次我这样做

Image1.Picture.LoadFromFile('c:\c.png');
Run Code Online (Sandbox Code Playgroud)

我得到:

正在读取的文件不是有效的"可移植网络图形"图像,因为它包含无效的标头.此文件可能已损坏,请尝试再次获取

现在我想这个问题是由这些行引起的(来自PngImage库):

{Characters for the header}
const
  PngHeader: Array[0..7] of Char = (#137, #80, #78, #71, #13, #10, #26, #10);

{Loads the image from a stream of data}
procedure TPngObject.LoadFromStream(Stream: TStream);
var
  Header    : Array[0..7] of Char;
  HasIDAT   : Boolean;

  {Chunks reading}
  ChunkCount : Cardinal;
  ChunkLength: Cardinal;
  ChunkName  : TChunkName;
begin
  {Initialize before start loading chunks}
  ChunkCount := 0;
  ClearChunks();
  {Reads the header}
  Stream.Read(Header[0], 8);

  {Test if the header matches}
  if Header <> PngHeader then
  begin …
Run Code Online (Sandbox Code Playgroud)

delphi png delphi-xe

3
推荐指数
1
解决办法
1万
查看次数

Primefaces数据表过滤不起作用

我正在尝试使用Primefaces 5制作表格过滤器,但过滤不会发生并获得跟随堆栈:

org.primefaces.component.datatable.feature.FilterFeature.filter(FilterFeature.java:136)中的java.lang.NullPointerException位于org.primefaces.component.datatable.feature.FilterFeature.encode(FilterFeature.java:105)的org. primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:77)at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1903)在com.sun.faces.context.PartialViewContextImpl $ PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:559)在com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)在org.primefaces.component.api .UIData.visitTree(UIData.java:692)在javax.faces.component.UIComponent.visitTree(UIComponent.java:1740)在javax.faces.component.UIComponent.visitTree(UIComponent.java:1740)在的com.sun. com.sun.faces.context.Par中的faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:399)tialViewContextImpl.processPartial(PartialViewContextImpl.java:319)在org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)在javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)在javax.faces.component .UIComponent.encodeAll(UIComponent.java:1896)位于com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:425)的com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java) :131)com.sun.faces.lifecycle.RenderponsePhase.exe(RenderResponsePhase.java:120)位于com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)的com.sun.faces.lifecycle. LifecycleImpl.render(LifecycleImpl.java:219)在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)在org.apache org.apache.tom上的.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)cat.websocket.server.WsFilter.doFilter(WsFilter.java:52)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.的java:206)在org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)在org.apache .catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)在com.star.AuthFilter.doFilter(AuthFilter.java:42)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)在org.apache.catalina.core.StandardContextValve.invoke( StandardContextValve.java:106)org.apache.catalina.authenticator.Authenti 位于org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)的catorBase.invoke(AuthenticatorBase.java:503)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)at org .apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter的.java:516)在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)在org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:652)在org.apache.coyote.在org.apache.tomcat.util.net.NioEndpoint $的org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1575)的http11.Http11NioProtocol $ Http11ConnectionHandler.process(Http11NioProtocol.java:222) SocketProcessor.run(NioEndpoint.java:1533)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExe)cutor.java:1142)java.lang.Thread.run上的java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)(Thread.java:745)

我克隆了primefaces展示的例子,但我没有把它弄好!

这是我的代码:xhtml文件:

<p:dataTable id="tbl" var="sim" value="#{simulationLog.simulation}"
                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                     paginator="true" rows="10" style="margin-bottom:20px"
                     filteredValue="#{simulationLog.filtredSimulation}"
                     >
            <p:column filterBy="#{sim.simId}" filterMatchMode="contains">
                <f:facet name="header">
                    <h:outputText value="Id" />
                </f:facet>
                <p:commandLink value="#{sim.simId}" />
            </p:column>
Run Code Online (Sandbox Code Playgroud)

支持豆:

@ManagedBean
@SessionScoped
public class SimulationLog implements Serializable {
    .
    .
    .
    private List<SimulationLog> simulation;
    private List<SimulationLog> filtredSimulation; …
Run Code Online (Sandbox Code Playgroud)

primefaces jsf-2

3
推荐指数
1
解决办法
6748
查看次数

具有聚合函数的多个mysql JOIN

我试图加入3桌

文章,股票和已售表 在此输入图像描述

我想为每篇文章选择表格中QteEntree的总和以及表格中Qte的总和来源我的代码

Select  Article.IdArt,
        Sum(sold.Qte),
        Sum(Stock.QteEntree)
from (((Article) 
        Left Join Sold on Sold.IdArt = Article.IdArt)
        Left Join Stock on Stock.IdArt = Article.IdArt)
Group by Article.IdArt
Run Code Online (Sandbox Code Playgroud)

但我总是得到(例如)Idte乘以QteEntree的结果为2,Qte的乘数结果乘以3我猜是因为我在Sold表中有2条记录而Stock表中有3条记录

我怎样才能解决这个问题?

谢谢

sql

2
推荐指数
1
解决办法
2279
查看次数

德尔福比较2个相似的图片

无论如何比较Delphi中的2个相似图像(不一样).

这里有些例子:

在此输入图像描述&在此输入图像描述

很明显,我们不能逐像素地比较,所以我的想法是将每个图像的像素值相加,比较它们:

function CalcPix( img : TImage) : longint;
var
  s : longint;
  i, j : integer;
begin
  s := 0;

  for i := 0 to img.Height do
  begin
     for j := 0 to img.Width do
     begin
      if img.Canvas.Pixels[i,j] <> clWhite then
        s := s + img.Canvas.Pixels[i, j];
     end;
  end;

  Result := S;
end;
Run Code Online (Sandbox Code Playgroud)

结果是:

1)14836072057

2)16750850318

正如你所看到的那样,它们并不是那么接近,如果我一次用4-5个图像进行这个过程,它总会给我错误的结果.

还有其他方法吗?喜欢改变颜色或对比度等

delphi compare image computer-vision

2
推荐指数
1
解决办法
3287
查看次数

使用Indy连接到Gmail

我正在尝试使用Delphi XE5通过Indy组件登录Gmail(而不是电子邮件),使用此功能:

procedure TForm1.Button1Click(Sender: TObject);
var
  http : TIdHTTP;
  S, GALX, Email, Pass : String;
  lParam : TStringList;

begin
  try
    lParam := TStringList.Create;
    try
      http := TIdHTTP.Create(nil);
      http.IOHandler := IOHandler;
      http.CookieManager := Cookie;
      http.AllowCookies := true;
      http.HandleRedirects := true;
      http.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0';
      http.Request.Host := 'accounts.google.com';
      http.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
      http.Request.ContentType := 'application/x-www-form-urlencoded';

      S := http.Get('https://accounts.google.com/ServiceLogin');

      Delete(S, 1, Pos('GALX', S));
      S := Copy(S, 1, Pos('">', S) - 1);
      Delete(S, 1, Pos('value=', S) + length('value='));

      GALX …
Run Code Online (Sandbox Code Playgroud)

delphi gmail indy10

2
推荐指数
1
解决办法
433
查看次数

使用openshift可视化tomcat服务器输出

我刚开始使用带有tomcat 7的openshift,我想知道你是否可以查看tomcat服务器输出,比如netbeans中的"Apache tomcat"窗口,你可以使用 System.out.println();

tomcat7 openshift

2
推荐指数
1
解决办法
1659
查看次数

德尔福的GIf资源

我正在尝试在delphi,res.RC文件中打开一个简单的资源(GIF):

Loading RCDATA "loadingAd.gif"
Run Code Online (Sandbox Code Playgroud)

码:

{$R *.dfm}
{$R res.RES}

procedure TForm1.Image1Click(Sender: TObject);
var h : THandle;
begin
   h := FindResource(HInstance, 'Loading', 'RCDATA');
   showmessage(IntToStr(h))
end;
Run Code Online (Sandbox Code Playgroud)

但每次我得到0,我都在使用XE4,所以我尝试过:

{$R *.dfm}
{$R res.RES}

procedure TForm1.Image1Click(Sender: TObject);
var h : THandle;
begin
   h := FindResource(HInstance, PChar('Loading'), PChar('RCDATA'));
   showmessage(IntToStr(h))
end;
Run Code Online (Sandbox Code Playgroud)

仍然得到"资源未找到".

delphi resources gif

0
推荐指数
1
解决办法
773
查看次数

delphi中的链式代理

我刚刚阅读了关于链接代理的内容,我想在delphi中尝试它,好吧我用indy TIdHttp组件玩,我无法弄清楚如何做到这一点,我需要两个TIdHttp组件吗?也许一个人将请求发送给另一个人?

  http1.ProxyParams.ProxyPort := Port1;
  http1.ProxyParams.ProxyServer := Server1;

  http2.ProxyParams.ProxyPort := Port2;
  http2.ProxyParams.ProxyServer := Server2;
Run Code Online (Sandbox Code Playgroud)

我只想用链式代理发送一些简单的GET/POST.

这甚至可行吗?或者还有其他任何组件来帮助我完成这项任务吗?

谢谢.

delphi proxy indy chained

-1
推荐指数
1
解决办法
751
查看次数